Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LIMIT statement to those queries needed during Pulp startup process. #6272

Merged
merged 1 commit into from
Feb 13, 2025

Conversation

decko
Copy link
Member

@decko decko commented Feb 12, 2025

The current query can be super heavy in environments with lots of
packages and really slow down the startup process of Pulp components.
Since we're checking the presence of any number of artifacts using a
certain checksum, limiting it to the first result can speed up the
check itself and the startup process.

The current query can be super heavy in environments with lots of
packages and really slow down the startup process of Pulp components.
Since we're checking the presence of any number of artifacts using a
certain checksum, limiting it to the first result can speed up the
check itself and the startup process.
@decko decko force-pushed the limit_checksum_startup_check branch from 1549aab to 72778a8 Compare February 12, 2025 16:08
cursor.execute(f"SELECT count(pulp_id) FROM core_artifact WHERE {checksum} IS NULL")
cursor.execute(
f"SELECT count(pulp_id) FROM core_artifact WHERE {checksum} IS NULL LIMIT 1"
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't EXISTS be a bit simpler?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't EXISTS a subquery operator? https://www.postgresql.org/docs/current/functions-subquery.html#FUNCTIONS-SUBQUERY-EXISTS

How could we use it in this context?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, the django .exists() doesn't map to the SQL concept of EXISTS as I thought it did.

@ggainey ggainey merged commit 9971e1b into main Feb 13, 2025
12 checks passed
@ggainey ggainey deleted the limit_checksum_startup_check branch February 13, 2025 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants