optimize queries for image-list

Bug #1211315 reported by Venkatesh Sampath
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Glance
Fix Released
Wishlist
Venkatesh Sampath

Bug Description

Get image list take lot of time for certain image-list criterias. Found through the explain plan and slow query logs that there is a full table scan happening on certain scenarios.

The fix is to refactor the get_image_list query building code to avoid full table scan and hence reduce the response time taken.

As part of the optimization of query the following fixes are to be done:
- avoid full table scan on images table by converting,
  images.is_public = 1 OR images.owner = 'OWNER'
  to
  query WHERE images.is_public = 1
  UNION
  query WHERE images.owner = 'OWNER'
- introduce missing index for owner column on images table.
- move image related conditions to the inner union queries
- remove unwanted union of queries in case of admin querying for image list
- change the condition images.status != 'killed' to images.status in ('active', 'saving', 'queued', 'pending_delete', 'deleted')
- convert the correlation subqueries that are used for image_property filters into inner joins

Changed in glance:
assignee: nobody → Venkatesh Sampath (venkateshsampath)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to glance (master)

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

Changed in glance:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

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

description: updated
description: updated
Changed in glance:
importance: Undecided → Wishlist
milestone: none → havana-3
Thierry Carrez (ttx)
Changed in glance:
milestone: havana-3 → havana-rc1
Changed in glance:
milestone: havana-rc1 → icehouse-1
Revision history for this message
Venkatesh Sampath (venkateshsampath) wrote :

Final fix proposed and review done is at the following location:
https://review.openstack.org/#/c/41404/

PS: This patch is dependent on a merged patch:
https://review.openstack.org/#/c/44801/9

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

Reviewed: https://review.openstack.org/41404
Committed: http://github.com/openstack/glance/commit/0e262d1ec7f5c7073a6d9f1d7bfadc3777b62297
Submitter: Jenkins
Branch: master

commit 0e262d1ec7f5c7073a6d9f1d7bfadc3777b62297
Author: Venkatesh Sampath <email address hidden>
Date: Wed Aug 21 16:59:10 2013 +0530

    optimize queries for image-list

    - avoid full table scan on images table by converting,
    images.is_public = 1 OR images.owner = 'OWNER'
    to
    query WHERE images.is_public = 1
    UNION
    query WHERE images.owner = 'OWNER'
    - move image related conditions to the inner union queries
    - remove unwanted union of queries in case of admin querying for image list
    - change the condition images.status != 'killed' to images.status in ('active', 'saving', 'queued', 'pending_delete', 'deleted')
    - convert the correlation subqueries that are used for image_property filters into inner joins

    Fixes bug 1211315

    depends on bug 1214830

    Change-Id: Ie7458044edbe1ef64871bcf5ef4996ed3cc0f957

Changed in glance:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in glance:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in glance:
milestone: icehouse-1 → 2014.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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