Skip to content

Conversation

@vithushau
Copy link

@vithushau vithushau commented Jul 11, 2025

Addresses issue #686

Query

EXPLAIN (ANALYZE, BUFFERS) SELECT tagsyncstatus, COUNT(tagsyncstatus) as statuscount
FROM {tool_objectfs_objects}
GROUP BY tagsyncstatus

Before Index

QUERY PLAN
Limit (cost=9458.77..9509.44 rows=200 width=10) (actual time=25.231..27.320 rows=1 loops=1)
Buffers: shared hit=1166 read=4592
-> Finalize GroupAggregate (cost=9458.77..9509.44 rows=200 width=10) (actual time=25.230..27.319 rows=1 loops=1)
Group Key: tagsyncstatus
Buffers: shared hit=1166 read=4592
-> Gather Merge (cost=9458.77..9505.44 rows=400 width=10) (actual time=25.224..27.313 rows=3 loops=1)
Workers Planned: 2
Workers Launched: 2
Buffers: shared hit=1166 read=4592
-> Sort (cost=8458.74..8459.24 rows=200 width=10) (actual time=22.668..22.669 rows=1 loops=3)
Sort Key: tagsyncstatus
Sort Method: quicksort Memory: 25kB
Buffers: shared hit=1166 read=4592
Worker 0: Sort Method: quicksort Memory: 25kB
Worker 1: Sort Method: quicksort Memory: 25kB
-> Partial HashAggregate (cost=8449.10..8451.10 rows=200 width=10) (actual time=22.654..22.655 rows=1 loops=3)
Group Key: tagsyncstatus
Batches: 1 Memory Usage: 40kB
Buffers: shared hit=1152 read=4592
Worker 0: Batches: 1 Memory Usage: 40kB
Worker 1: Batches: 1 Memory Usage: 40kB
-> Parallel Seq Scan on mdl_tool_objectfs_objects (cost=0.00..7547.40 rows=180340 width=2) (actual time=0.018..11.493 rows=144272 loops=3)
Buffers: shared hit=1152 read=4592
Planning:
Buffers: shared hit=57
Planning Time: 0.120 ms
Execution Time: 27.342 ms

After Index

Limit (cost=1000.45..7469.80 rows=200 width=10) (actual time=15.054..16.905 rows=1 loops=1)
Buffers: shared hit=370
-> Finalize GroupAggregate (cost=1000.45..7469.80 rows=200 width=10) (actual time=15.053..16.904 rows=1 loops=1)
Group Key: tagsyncstatus
Buffers: shared hit=370
-> Gather Merge (cost=1000.45..7465.80 rows=400 width=10) (actual time=15.050..16.900 rows=3 loops=1)
Workers Planned: 2
Workers Launched: 2
Buffers: shared hit=370
-> Partial GroupAggregate (cost=0.42..6419.60 rows=200 width=10) (actual time=12.577..12.577 rows=1 loops=3)
Group Key: tagsyncstatus
Buffers: shared hit=370
-> Parallel Index Only Scan using mdl_toolobjeobje_tag_ix on mdl_tool_objectfs_objects (cost=0.42..5515.90 rows=180340 width=2) (actual time=0.023..6.061 rows=144272 loops=3)
Heap Fetches: 0
Buffers: shared hit=370
Planning:
Buffers: shared hit=71
Planning Time: 0.146 ms
Execution Time: 16.923 ms

@vithushau vithushau force-pushed the issue-686-optimize-tagsummary branch 2 times, most recently from 53db674 to 858194d Compare July 11, 2025 06:43
@vithushau vithushau force-pushed the issue-686-optimize-tagsummary branch from 858194d to 248ffa7 Compare July 17, 2025 03:58
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