OCA / queue

Asynchronous Job Queue
GNU Affero General Public License v3.0
173 stars 442 forks source link

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

Closed sebalix closed 4 months ago

sebalix commented 4 months ago

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 commented 4 months ago

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

sebalix commented 4 months ago

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

simahawk commented 4 months ago

/ocabot merge patch

@sebalix could you fwd port it pls?

OCA-git-bot commented 4 months ago

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 commented 4 months ago

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

sebalix commented 4 months ago

@simahawk @guewen ported missing commits: