Faster cache lookup by removing a join with the ImagePlacementTable, removing the extra loop to add the locations and filtering the images looked up by the base image

This commit is contained in:
Joseph Schorr 2015-04-24 16:22:19 -04:00
parent fd65ca5916
commit e70343d849
3 changed files with 39 additions and 1 deletions

View file

@ -1751,6 +1751,21 @@ def get_matching_repository_images(namespace_name, repository_name, docker_image
return _get_repository_images_base(namespace_name, repository_name, modify_query)
def get_repository_images_directly(repository, with_ancestor=None):
query = (Image
.select(Image, ImageStorage)
.join(ImageStorage)
.where(Image.repository == repository))
if with_ancestor:
ancestors_string = '%s%s/' % (with_ancestor.ancestors, with_ancestor.id)
query = query.where((Image.ancestors ** (ancestors_string + '%')) |
(Image.id == with_ancestor.id))
return query
def get_repository_images(namespace_name, repository_name):
return _get_repository_images_base(namespace_name, repository_name, lambda q: q)