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
Fix proposed to branch: master /review. openstack. org/41404
Review: https:/