61 lines
2.2 KiB
Plaintext
61 lines
2.2 KiB
Plaintext
BEGIN
|
|
Timing is on.
|
|
ANALYZE
|
|
Time: 117.334 ms
|
|
chat_id | messages_count
|
|
--------------------------------------+----------------
|
|
f68eff95-e44f-4c79-997c-49eb725cfb4d | 90005
|
|
b14d0a4f-3046-44b2-871e-4ebfb752c543 | 11613
|
|
41d9abbc-4d0b-44f7-a1a2-ea3de4faa0c3 | 10942
|
|
1b7b678e-d262-4d61-8167-7fc8b736f3ff | 10005
|
|
0d8c7368-f88a-4bdb-972e-e4d7e1cd437a | 5
|
|
(5 rows)
|
|
|
|
Time: 10.412 ms
|
|
Time: 8.597 ms
|
|
TEST A: existing composite index
|
|
QUERY PLAN
|
|
-------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Limit (cost=0.42..6.74 rows=50 width=45) (actual time=0.025..0.036 rows=50 loops=1)
|
|
Buffers: shared hit=3 read=2
|
|
-> Index Scan using idx_messages_chat_created_id on messages (cost=0.42..11395.89 rows=90150 width=45) (actual time=0.024..0.033 rows=50 loops=1)
|
|
Index Cond: (chat_id = 'f68eff95-e44f-4c79-997c-49eb725cfb4d'::uuid)
|
|
Buffers: shared hit=3 read=2
|
|
Planning:
|
|
Buffers: shared hit=10
|
|
Planning Time: 0.069 ms
|
|
Execution Time: 0.044 ms
|
|
(9 rows)
|
|
|
|
Time: 0.360 ms
|
|
TEST B: additional index
|
|
CREATE INDEX
|
|
Time: 0.285 ms
|
|
ANALYZE
|
|
Time: 123.698 ms
|
|
QUERY PLAN
|
|
-------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Limit (cost=0.42..6.75 rows=50 width=45) (actual time=0.007..0.014 rows=50 loops=1)
|
|
Buffers: shared hit=5
|
|
-> Index Scan using idx_messages_chat_created_id on messages (cost=0.42..11378.89 rows=89905 width=45) (actual time=0.006..0.011 rows=50 loops=1)
|
|
Index Cond: (chat_id = 'f68eff95-e44f-4c79-997c-49eb725cfb4d'::uuid)
|
|
Buffers: shared hit=5
|
|
Planning:
|
|
Buffers: shared hit=15
|
|
Planning Time: 0.081 ms
|
|
Execution Time: 0.023 ms
|
|
(9 rows)
|
|
|
|
Time: 0.279 ms
|
|
Index sizes
|
|
indexrelname | size
|
|
------------------------------+---------
|
|
idx_messages_chat_created_id | 9328 kB
|
|
idx_messages_chat_id_only | 1016 kB
|
|
messages_pkey | 5392 kB
|
|
(3 rows)
|
|
|
|
Time: 1.366 ms
|
|
ROLLBACK
|
|
Time: 0.119 ms
|