bw_usage_update makes an unnecessary query

Bug #1036084 reported by Chris Behrens
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Chris Behrens

Bug Description

bw_usage_update() in sqlalchemy api always does a select before doing an update or create. It needn't do this. It could just try to update and if 0 rows are updated, then create an entry. In the most common case (updating an existing row), this will result in 1 DB query vs 2.

Chris Behrens (cbehrens)
Changed in nova:
importance: Undecided → Medium
assignee: nobody → Chris Behrens (cbehrens)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/11267

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/11267
Committed: http://github.com/openstack/nova/commit/7a500ecc8799914e45ca8534a15f81b8823a1d3e
Submitter: Jenkins
Branch: master

commit 7a500ecc8799914e45ca8534a15f81b8823a1d3e
Author: Chris Behrens <email address hidden>
Date: Mon Aug 13 07:33:15 2012 +0000

    Improve bw_usage_update() performance

    Fixes bug 1036084

    bw_usage_update() most commonly updates rows vs creates rows. New rows
    are only created on the 1st bandwidth update for an instance or when
    the audit period rolls over. This cuts down DB queries to 1 for the
    'update' case.

    Added bonus:
    Remove unused 'import inspect' in compute manager.

    Change-Id: Ie5f6c919676046d817b842138dc9d17d1115d3c0

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → folsom-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: folsom-3 → 2012.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.