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

[14.0] queue_job: fix partial index to add wait_dependencies state #629

Merged
merged 1 commit into from
Mar 6, 2024

Conversation

sebalix
Copy link
Contributor

@sebalix sebalix commented Mar 6, 2024

Some details about the search performed by the method job_record_with_same_identity_key in file queue_job/job.py, the partial index wasn't used before:

Before

 Limit  (cost=6874.52..6874.53 rows=1 width=20) (actual time=0.123..0.123 rows=0 loops=1)
   ->  Sort  (cost=6874.52..6874.53 rows=1 width=20) (actual time=0.121..0.121 rows=0 loops=1)
         Sort Key: date_created DESC, date_done DESC
         Sort Method: quicksort  Memory: 25kB
         ->  Index Scan using queue_job_state_index on queue_job  (cost=0.42..6874.51 rows=1 width=20) (actual time=0.113..0.113 rows=0 loops=1)
               Index Cond: ((state)::text = ANY ('{wait_dependencies,pending,enqueued}'::text[]))
               Filter: ((identity_key)::text = 'f75c2b628243d651bad356030a3021a95dbe7725'::text)
 Planning Time: 0.375 ms
 Execution Time: 0.161 ms

After

 Limit  (cost=8.15..8.16 rows=1 width=20) (actual time=0.032..0.032 rows=0 loops=1)
   ->  Sort  (cost=8.15..8.16 rows=1 width=20) (actual time=0.030..0.030 rows=0 loops=1)
         Sort Key: date_created DESC, date_done DESC
         Sort Method: quicksort  Memory: 25kB
         ->  Index Scan using queue_job_identity_key_state_partial_index on queue_job  (cost=0.12..8.14 rows=1 width=20) (actual time=0.019..0.019 rows=0 loops=1)
               Index Cond: ((identity_key)::text = 'f75c2b628243d651bad356030a3021a95dbe7725'::text)
 Planning Time: 0.844 ms
 Execution Time: 0.094 ms

@OCA-git-bot
Copy link
Contributor

Hi @guewen,
some modules you are maintaining are being modified, check this out!

@sebalix sebalix marked this pull request as ready for review March 6, 2024 11:09
@sebalix sebalix force-pushed the 14-queue_job-fix-partial-index branch 2 times, most recently from 6a47170 to ba9f49c Compare March 6, 2024 11:22
@sebalix
Copy link
Contributor Author

sebalix commented Mar 6, 2024

Added a pre-migration script to drop the index to get it re-created automatically during the module update.

@sebalix sebalix force-pushed the 14-queue_job-fix-partial-index branch from ba9f49c to fe4fe95 Compare March 6, 2024 11:25
@simahawk
Copy link
Contributor

simahawk commented Mar 6, 2024

/ocabot merge patch

@sebalix could you fwd port it pls?

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 14.0-ocabot-merge-pr-629-by-simahawk-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit bde03d6 into OCA:14.0 Mar 6, 2024
7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 4c824c2. Thanks a lot for contributing to OCA. ❤️

@sebalix sebalix deleted the 14-queue_job-fix-partial-index branch March 6, 2024 12:29
@sebalix
Copy link
Contributor Author

sebalix commented Mar 6, 2024

@simahawk @guewen ported missing commits:

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.

4 participants