Improve "NeutronDbObject.objects_exist" performance
Bug #1925528 reported by
Rodolfo Alonso
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
neutron |
Fix Released
|
Wishlist
|
Rodolfo Alonso |
Bug Description
Current "NeutronDbObjec
This query can be optimized by:
- Limiting the number of registers to be retrieved to only one. The goal of the "objects_exist" method is to know if there are objects or not. Finding one is enough
- Limiting the complexity of the query by requesting only one column, provided as a method parameter, that could be, for example, the ID.
Changed in neutron: | |
importance: | Undecided → Wishlist |
assignee: | nobody → Rodolfo Alonso (rodolfo-alonso-hernandez) |
To post a comment you must log in.
As an example, using the method "DbBasePluginCo mmon._is_ mac_in_ use". This is called when you create a port passing the MAC address. An easy example to test.
The query at [1], that is called from [2], called from "objects_exist", is [3].
If we instead query by one single parameter, "id" for example (Port OVO has ID), the query is:
SELECT ports.id AS ports_id
FROM ports
WHERE ports.network_id IN (%(network_id_1)s) AND ports.mac_address IN (%(mac_address_1)s)
This is clearly a much easier query to be processed by the DB backend.
[1]https:/ /github. com/openstack/ neutron/ blob/98c934ef6a 8041bbd7b99ac49 f53986798e8ef81 /neutron/ objects/ db/api. py#L28 /github. com/openstack/ neutron/ blob/98c934ef6a 8041bbd7b99ac49 f53986798e8ef81 /neutron/ objects/ db/api. py#L36 paste.openstack .org/show/ 804727/
[2]https:/
[3]http://