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

[PERF] runbot: remove row_number queries #1008

Open
wants to merge 1 commit into
base: 18.0
Choose a base branch
from

Conversation

Williambraecky
Copy link
Contributor

The row_number window function is quite unoptimized as it requires reading the whole table.
Using lateral join and / or distinct makes better use of existing indexes.

@C3POdoo C3POdoo requested a review from a team December 5, 2024 12:32
@Williambraecky
Copy link
Contributor Author

@Xavier-Do would be worth it to run an explain (analyse) on those queries on prod/mirror just to check if it saves any time at all.

for batch in batchs:
batch_ids[batch.bundle_id.id].append(batch.id)

SELECT bundle.id, ARRAY_AGG(batch.id)
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar in perfs to the previous, except with create index runbot_batch__bundle_id_id_desc_index on runbot_batch (bundle_id, id desc); Blazing fast !!!!!!

@Williambraecky Williambraecky force-pushed the 17.0-remove-row-number-wbr branch 2 times, most recently from b91b827 to 10001bc Compare December 5, 2024 14:52
The row_number window function is quite unoptimized as it requires
reading the whole table.
Using lateral join and / or distinct makes better use of existing
indexes.
@Williambraecky Williambraecky changed the base branch from 17.0 to 18.0 January 22, 2025 14:08
@Williambraecky Williambraecky force-pushed the 17.0-remove-row-number-wbr branch from 10001bc to b659c73 Compare January 22, 2025 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants