Lab2
This commit is contained in:
+37
-37
@@ -5,64 +5,64 @@ PASS: chat row was rolled back together with members
|
||||
PASS: no chats without members exist in the database
|
||||
|
||||
== EXPLAIN for message history pagination
|
||||
messages total: 83665; in explained chat: 10000
|
||||
messages total: 50003; in explained chat: 10000
|
||||
PASS: explained chat has >= 10 000 messages
|
||||
|
||||
-- first page
|
||||
Limit (actual time=0.014..0.022 rows=51 loops=1)
|
||||
Limit (actual time=0.010..0.016 rows=51 loops=1)
|
||||
Buffers: shared hit=4
|
||||
-> Index Scan using messages_keyset_idx on messages (actual time=0.013..0.019 rows=51 loops=1)
|
||||
Index Cond: (chat_id = 'd00c8d51-a786-404d-aea9-c8447ec0614b'::uuid)
|
||||
-> Index Scan using messages_keyset_idx on messages (actual time=0.010..0.013 rows=51 loops=1)
|
||||
Index Cond: (chat_id = '7c57b8e9-42a1-4cf8-904b-08545328a890'::uuid)
|
||||
Buffers: shared hit=4
|
||||
Planning:
|
||||
Buffers: shared hit=6
|
||||
Planning Time: 0.096 ms
|
||||
Execution Time: 0.045 ms
|
||||
Planning Time: 0.131 ms
|
||||
Execution Time: 0.035 ms
|
||||
|
||||
-- keyset page after position 9000
|
||||
Limit (actual time=0.025..0.036 rows=51 loops=1)
|
||||
Buffers: shared hit=4 read=1
|
||||
-> Index Scan using messages_keyset_idx on messages (actual time=0.024..0.032 rows=51 loops=1)
|
||||
Index Cond: ((chat_id = 'd00c8d51-a786-404d-aea9-c8447ec0614b'::uuid) AND (ROW(created_at, id) > ROW('2026-09-28 16:11:52.757537+00'::timestamp with time zone, 'cab6bb16-0f15-46a0-8f5e-13cb8416fd5e'::uuid)))
|
||||
Buffers: shared hit=4 read=1
|
||||
Planning Time: 0.058 ms
|
||||
Execution Time: 0.097 ms
|
||||
Limit (actual time=0.012..0.021 rows=51 loops=1)
|
||||
Buffers: shared hit=5
|
||||
-> Index Scan using messages_keyset_idx on messages (actual time=0.011..0.018 rows=51 loops=1)
|
||||
Index Cond: ((chat_id = '7c57b8e9-42a1-4cf8-904b-08545328a890'::uuid) AND (ROW(created_at, id) > ROW('2026-10-01 07:31:21.6187+00'::timestamp with time zone, '6cbb1e03-f1e2-4113-8a7b-612c90c9761f'::uuid)))
|
||||
Buffers: shared hit=5
|
||||
Planning Time: 0.043 ms
|
||||
Execution Time: 0.104 ms
|
||||
|
||||
-- OFFSET 9000 (not used by the API)
|
||||
Limit (actual time=5.664..5.672 rows=51 loops=1)
|
||||
Buffers: shared hit=265
|
||||
-> Sort (actual time=4.983..5.386 rows=9051 loops=1)
|
||||
Limit (actual time=3.723..3.729 rows=51 loops=1)
|
||||
Buffers: shared hit=207
|
||||
-> Sort (actual time=3.127..3.460 rows=9051 loops=1)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: quicksort Memory: 1713kB
|
||||
Buffers: shared hit=265
|
||||
-> Bitmap Heap Scan on messages (actual time=0.311..1.323 rows=10000 loops=1)
|
||||
Recheck Cond: (chat_id = 'd00c8d51-a786-404d-aea9-c8447ec0614b'::uuid)
|
||||
Buffers: shared hit=207
|
||||
-> Bitmap Heap Scan on messages (actual time=0.321..0.920 rows=10000 loops=1)
|
||||
Recheck Cond: (chat_id = '7c57b8e9-42a1-4cf8-904b-08545328a890'::uuid)
|
||||
Heap Blocks: exact=134
|
||||
Buffers: shared hit=265
|
||||
-> Bitmap Index Scan on messages_keyset_idx (actual time=0.291..0.292 rows=10000 loops=1)
|
||||
Index Cond: (chat_id = 'd00c8d51-a786-404d-aea9-c8447ec0614b'::uuid)
|
||||
Buffers: shared hit=131
|
||||
Planning Time: 0.132 ms
|
||||
Execution Time: 5.876 ms
|
||||
Buffers: shared hit=207
|
||||
-> Bitmap Index Scan on messages_keyset_idx (actual time=0.307..0.308 rows=10000 loops=1)
|
||||
Index Cond: (chat_id = '7c57b8e9-42a1-4cf8-904b-08545328a890'::uuid)
|
||||
Buffers: shared hit=73
|
||||
Planning Time: 0.040 ms
|
||||
Execution Time: 3.848 ms
|
||||
|
||||
-- keyset page WITHOUT messages_keyset_idx (rolled back)
|
||||
Limit (actual time=5.998..6.007 rows=51 loops=1)
|
||||
Buffers: shared hit=1106
|
||||
-> Sort (actual time=5.996..5.999 rows=51 loops=1)
|
||||
Limit (actual time=1.882..1.886 rows=51 loops=1)
|
||||
Buffers: shared hit=667
|
||||
-> Sort (actual time=1.880..1.882 rows=51 loops=1)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: top-N heapsort Memory: 31kB
|
||||
Buffers: shared hit=1106
|
||||
-> Seq Scan on messages (actual time=1.232..5.880 rows=999 loops=1)
|
||||
Filter: ((chat_id = 'd00c8d51-a786-404d-aea9-c8447ec0614b'::uuid) AND (ROW(created_at, id) > ROW('2026-09-28 16:11:52.757537+00'::timestamp with time zone, 'cab6bb16-0f15-46a0-8f5e-13cb8416fd5e'::uuid)))
|
||||
Rows Removed by Filter: 82666
|
||||
Buffers: shared hit=1106
|
||||
Buffers: shared hit=667
|
||||
-> Seq Scan on messages (actual time=0.386..1.804 rows=999 loops=1)
|
||||
Filter: ((chat_id = '7c57b8e9-42a1-4cf8-904b-08545328a890'::uuid) AND (ROW(created_at, id) > ROW('2026-10-01 07:31:21.6187+00'::timestamp with time zone, '6cbb1e03-f1e2-4113-8a7b-612c90c9761f'::uuid)))
|
||||
Rows Removed by Filter: 49004
|
||||
Buffers: shared hit=667
|
||||
Planning:
|
||||
Buffers: shared hit=4
|
||||
Planning Time: 0.166 ms
|
||||
Execution Time: 6.063 ms
|
||||
Planning Time: 0.088 ms
|
||||
Execution Time: 1.920 ms
|
||||
PASS: first page reads the index in order, no Sort
|
||||
PASS: keyset cursor is an Index Cond, not a filter over the history
|
||||
PASS: keyset deep page touches fewer buffers than OFFSET (5 < 265)
|
||||
PASS: index reduces buffers for the deep page (5 < 1106)
|
||||
PASS: keyset deep page touches fewer buffers than OFFSET (5 < 207)
|
||||
PASS: index reduces buffers for the deep page (5 < 667)
|
||||
|
||||
PASS: db checks
|
||||
|
||||
Reference in New Issue
Block a user