Fix DB performance with sessions
Commit 9d15b98261 added a method to
get objects from the DB (OVO or otherwise). This introduced a
performance problem, as seen when running "neutron port-list" with
a large number of neutron ports. On one setup with 6.5k ports, the
port-list time was on the order of several minutes. This patch makes
a minor change to this method, and imports sqlalchemy instead of just
the inspect method from that library. This reduced the same port-list
time to a low double-digit number of seconds. This follows the same
pattern that was introduced in upstream neutron (see this patch:
https://review.opendev.org/c/openstack/neutron/+/428779).
Change-Id: Id43811d2526566a466747d7e94bde8fd82430355
This commit is contained in:
committed by
Thomas Bachman
parent
51d6e20974
commit
b40c1b7b09
@@ -20,7 +20,7 @@
|
||||
# corresponding to the newest neutron branch supported by this
|
||||
# repository.
|
||||
|
||||
from sqlalchemy import inspect
|
||||
import sqlalchemy
|
||||
|
||||
import neutron.objects.base as n_base
|
||||
from neutron_lib.db import api
|
||||
@@ -48,7 +48,7 @@ def get_session_from_obj(db_obj):
|
||||
if isinstance(db_obj, n_base.NeutronObject):
|
||||
return db_obj.obj_context.session
|
||||
try:
|
||||
instance = inspect(db_obj)
|
||||
instance = sqlalchemy.inspect(db_obj)
|
||||
return instance.session
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user