Skip to content

Commit

Permalink
Exclude total field from Pyxis request's projection
Browse files Browse the repository at this point in the history
The requests in find_images_by_installed_rpms API are very inefficient,
including the `total` field can make the query performance much worse.
  • Loading branch information
qixiang committed Sep 18, 2023
1 parent e2f31bd commit 0ced85a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions freshmaker/pyxis_gql.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,6 @@ def find_images_by_installed_rpms(
),
ds.ContainerImagePaginatedResponse.page,
ds.ContainerImagePaginatedResponse.page_size,
ds.ContainerImagePaginatedResponse.total,
ds.ContainerImagePaginatedResponse.data.select(*self._get_image_projection()),
)

Expand All @@ -510,8 +509,8 @@ def find_images_by_installed_rpms(
]
images.extend(data)

# If page_size >= total, means all results have been fetched in the first page
if result["find_images"]["page_size"] >= result["find_images"]["total"]:
# This page has less items than the page size, it's the last page
if len(data) < result["find_images"]["page_size"]:
break
page_num += 1

Expand Down
5 changes: 2 additions & 3 deletions freshmaker/pyxis_gql_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@ async def find_images_by_installed_rpms(
),
ds.ContainerImagePaginatedResponse.page,
ds.ContainerImagePaginatedResponse.page_size,
ds.ContainerImagePaginatedResponse.total,
ds.ContainerImagePaginatedResponse.data.select(*self._get_image_projection()),
)

Expand All @@ -531,8 +530,8 @@ async def find_images_by_installed_rpms(
]
images.extend(data)

# If page_size >= total, means all results have been fetched in the first page
if result["find_images"]["page_size"] >= result["find_images"]["total"]: # type: ignore[index]
# This page has less items than the page size, it's the last page
if len(data) < result["find_images"]["page_size"]: # type: ignore[index]
break
page_num += 1

Expand Down

0 comments on commit 0ced85a

Please sign in to comment.