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

indexer: Add index to manifest_index table to aid deletions #911

Merged
merged 2 commits into from
May 18, 2023

Conversation

crozzy
Copy link
Contributor

@crozzy crozzy commented Apr 18, 2023

By deleting a broad index for space reasons (
d9abe3d) I inadvertantly slowed the delete manifests query due to a delete cascading to the manifest_index table and having to do a seq scan. This change adds a dedicated index for queries involving manifest_id.

@crozzy crozzy requested a review from a team as a code owner April 18, 2023 22:07
@crozzy crozzy requested review from RTann and removed request for a team April 18, 2023 22:07
@crozzy
Copy link
Contributor Author

crozzy commented Apr 18, 2023

Query log after adding index:
$ go test -v -timeout 30s -run ^TestDeleteManifests$ github.com/quay/claircore/datastore/postgres

2023-04-18 14:41:37.556 PDT [2525748] LOG:  duration: 0.006 ms  plan:
	Query Text: DELETE FROM ONLY "public"."manifest_index" WHERE $1 OPERATOR(pg_catalog.=) "manifest_id"
	Delete on public.manifest_index  (cost=4.20..13.67 rows=0 width=0) (actual time=0.005..0.005 rows=0 loops=1)
	  Buffers: shared hit=2
	  ->  Bitmap Heap Scan on public.manifest_index  (cost=4.20..13.67 rows=6 width=6) (actual time=0.004..0.005 rows=0 loops=1)
	        Output: ctid
	        Recheck Cond: ('1'::bigint = manifest_index.manifest_id)
	        Buffers: shared hit=2
	        ->  Bitmap Index Scan on idx_manifest_index_manifest_id  (cost=0.00..4.20 rows=6 width=0) (actual time=0.002..0.002 rows=0 loops=1)
	              Index Cond: (manifest_index.manifest_id = '1'::bigint)
	              Buffers: shared hit=2

@crozzy crozzy requested review from hdonnay and removed request for RTann April 18, 2023 22:11
Copy link
Member

@hdonnay hdonnay left a comment

Choose a reason for hiding this comment

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

Could you please split the change to the integration package to another commit?

@crozzy crozzy requested a review from hdonnay April 20, 2023 21:17
hdonnay
hdonnay previously approved these changes May 1, 2023
Copy link
Member

@hdonnay hdonnay left a comment

Choose a reason for hiding this comment

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

LGTM

By deleting a broad index for space reasons (
quay@d9abe3d)
I inadvertently slowed the delete manifests query due to a delete
cascading to the manifest_index table and having to do a seq scan. This
change adds a dedicated index for queries involving manifest_id.

Signed-off-by: crozzy <joseph.crosland@gmail.com>
Add the above options to log the nested statements that are executed
during test runs.

Signed-off-by: crozzy <joseph.crosland@gmail.com>
@hdonnay hdonnay merged commit d231a17 into quay:main May 18, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants