forked from mtusi2026/mtusi2026lab2
справление: U+0000 в строках сохраняется (bytea), DataError -> 400
This commit is contained in:
Binary file not shown.
@@ -1,7 +1,7 @@
|
||||
=== Data volume
|
||||
messages_total | messages_in_big_chat
|
||||
----------------+----------------------
|
||||
20116 | 15000
|
||||
20250 | 15000
|
||||
|
||||
|
||||
=== History index
|
||||
@@ -13,58 +13,58 @@
|
||||
=== 1. First page: limit=50, the app asks for 51 rows to know if there is a next page
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------
|
||||
Limit (actual time=0.007..0.012 rows=51 loops=1)
|
||||
Limit (actual time=0.005..0.011 rows=51 loops=1)
|
||||
Buffers: shared hit=4
|
||||
-> Index Scan using messages_history on messages (actual time=0.007..0.009 rows=51 loops=1)
|
||||
Index Cond: (chat_id = '6a75871f-4837-4b3c-b7c8-1c36de87da98'::uuid)
|
||||
-> Index Scan using messages_history on messages (actual time=0.004..0.008 rows=51 loops=1)
|
||||
Index Cond: (chat_id = 'edccb516-a15c-427e-a8d3-9b1b2d9ea77c'::uuid)
|
||||
Buffers: shared hit=4
|
||||
Planning:
|
||||
Buffers: shared hit=8
|
||||
Planning Time: 0.155 ms
|
||||
Execution Time: 0.028 ms
|
||||
Buffers: shared hit=6
|
||||
Planning Time: 0.055 ms
|
||||
Execution Time: 0.020 ms
|
||||
|
||||
|
||||
=== 2. Page after the 10000th message by keyset cursor (this is what the app does)
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (actual time=0.006..0.012 rows=51 loops=1)
|
||||
Buffers: shared hit=6
|
||||
-> Index Scan using messages_history on messages (actual time=0.006..0.010 rows=51 loops=1)
|
||||
Index Cond: ((chat_id = '6a75871f-4837-4b3c-b7c8-1c36de87da98'::uuid) AND (ROW(created_at, id) > ROW('2026-09-01 02:46:40+00'::timestamp with time zone, 'd867a7e3-2b56-475a-81c9-19729e8336c2'::uuid)))
|
||||
Buffers: shared hit=6
|
||||
Limit (actual time=0.006..0.011 rows=51 loops=1)
|
||||
Buffers: shared hit=4
|
||||
-> Index Scan using messages_history on messages (actual time=0.006..0.008 rows=51 loops=1)
|
||||
Index Cond: ((chat_id = 'edccb516-a15c-427e-a8d3-9b1b2d9ea77c'::uuid) AND (ROW(created_at, id) > ROW('2026-09-01 02:46:40+00'::timestamp with time zone, '3b67880a-c02c-48ac-aec2-1a0331e99fee'::uuid)))
|
||||
Buffers: shared hit=4
|
||||
Planning Time: 0.038 ms
|
||||
Execution Time: 0.031 ms
|
||||
Execution Time: 0.028 ms
|
||||
|
||||
|
||||
=== 3. The same page with OFFSET 10000 (the app does NOT do this)
|
||||
QUERY PLAN
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Limit (actual time=0.716..0.721 rows=51 loops=1)
|
||||
Buffers: shared hit=257
|
||||
-> Index Scan using messages_history on messages (actual time=0.008..0.521 rows=10051 loops=1)
|
||||
Index Cond: (chat_id = '6a75871f-4837-4b3c-b7c8-1c36de87da98'::uuid)
|
||||
Buffers: shared hit=257
|
||||
Planning Time: 0.028 ms
|
||||
Limit (actual time=0.747..0.752 rows=51 loops=1)
|
||||
Buffers: shared hit=199
|
||||
-> Index Scan using messages_history on messages (actual time=0.006..0.566 rows=10051 loops=1)
|
||||
Index Cond: (chat_id = 'edccb516-a15c-427e-a8d3-9b1b2d9ea77c'::uuid)
|
||||
Buffers: shared hit=199
|
||||
Planning Time: 0.033 ms
|
||||
Execution Time: 0.765 ms
|
||||
|
||||
|
||||
=== 4. Query 2 without the index (index is dropped only inside this transaction)
|
||||
QUERY PLAN
|
||||
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (actual time=0.862..0.865 rows=51 loops=1)
|
||||
Buffers: shared hit=255
|
||||
-> Sort (actual time=0.861..0.863 rows=51 loops=1)
|
||||
Limit (actual time=0.895..0.898 rows=51 loops=1)
|
||||
Buffers: shared hit=251
|
||||
-> Sort (actual time=0.895..0.896 rows=51 loops=1)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: top-N heapsort Memory: 31kB
|
||||
Buffers: shared hit=255
|
||||
-> Seq Scan on messages (actual time=0.289..0.686 rows=5000 loops=1)
|
||||
Filter: ((chat_id = '6a75871f-4837-4b3c-b7c8-1c36de87da98'::uuid) AND (ROW(created_at, id) > ROW('2026-09-01 02:46:40+00'::timestamp with time zone, 'd867a7e3-2b56-475a-81c9-19729e8336c2'::uuid)))
|
||||
Rows Removed by Filter: 15116
|
||||
Buffers: shared hit=255
|
||||
Buffers: shared hit=251
|
||||
-> Seq Scan on messages (actual time=0.320..0.719 rows=5000 loops=1)
|
||||
Filter: ((chat_id = 'edccb516-a15c-427e-a8d3-9b1b2d9ea77c'::uuid) AND (ROW(created_at, id) > ROW('2026-09-01 02:46:40+00'::timestamp with time zone, '3b67880a-c02c-48ac-aec2-1a0331e99fee'::uuid)))
|
||||
Rows Removed by Filter: 15250
|
||||
Buffers: shared hit=251
|
||||
Planning:
|
||||
Buffers: shared hit=4
|
||||
Planning Time: 0.051 ms
|
||||
Execution Time: 0.884 ms
|
||||
Planning Time: 0.043 ms
|
||||
Execution Time: 0.912 ms
|
||||
|
||||
|
||||
=== ROLLBACK: test data removed, index is back
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user