forked from mtusi2026/mtusi2026lab4
4: исправление по ревью — проверка смысла чанков PNG (палитра, tRNS, порядок, текст), регрессионные тесты, evidence
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
=== Data volume
|
||||
messages_total | messages_in_big_chat
|
||||
----------------+----------------------
|
||||
20146 | 15000
|
||||
35618 | 15000
|
||||
|
||||
|
||||
=== History index
|
||||
@@ -13,39 +13,39 @@
|
||||
=== 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.005..0.011 rows=51 loops=1)
|
||||
Buffers: shared hit=5
|
||||
Limit (actual time=0.006..0.010 rows=51 loops=1)
|
||||
Buffers: shared hit=4
|
||||
-> Index Scan using messages_history on messages (actual time=0.005..0.008 rows=51 loops=1)
|
||||
Index Cond: (chat_id = '7c307498-c398-4a1e-be96-13556a559cbf'::uuid)
|
||||
Buffers: shared hit=5
|
||||
Index Cond: (chat_id = '872415a3-3ab7-4e2b-bbc5-e5d03904fd1d'::uuid)
|
||||
Buffers: shared hit=4
|
||||
Planning:
|
||||
Buffers: shared hit=6
|
||||
Planning Time: 0.060 ms
|
||||
Buffers: shared hit=8
|
||||
Planning Time: 0.071 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.005..0.012 rows=51 loops=1)
|
||||
Buffers: shared hit=6
|
||||
-> Index Scan using messages_history on messages (actual time=0.005..0.009 rows=51 loops=1)
|
||||
Index Cond: ((chat_id = '7c307498-c398-4a1e-be96-13556a559cbf'::uuid) AND (ROW(created_at, id) > ROW('2026-09-01 02:46:40+00'::timestamp with time zone, '170ea586-3f7e-4314-a9bf-8e4f394941ac'::uuid)))
|
||||
Buffers: shared hit=6
|
||||
Planning Time: 0.044 ms
|
||||
Execution Time: 0.031 ms
|
||||
Limit (actual time=0.006..0.011 rows=51 loops=1)
|
||||
Buffers: shared hit=5
|
||||
-> Index Scan using messages_history on messages (actual time=0.005..0.008 rows=51 loops=1)
|
||||
Index Cond: ((chat_id = '872415a3-3ab7-4e2b-bbc5-e5d03904fd1d'::uuid) AND (ROW(created_at, id) > ROW('2026-09-01 02:46:40+00'::timestamp with time zone, '4bd22867-547f-4ecf-8182-443fbb004188'::uuid)))
|
||||
Buffers: shared hit=5
|
||||
Planning Time: 0.040 ms
|
||||
Execution Time: 0.029 ms
|
||||
|
||||
|
||||
=== 2b. The same page exactly as the app sends it since lab4: with attachment_ids of every message
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (actual time=0.020..0.225 rows=51 loops=1)
|
||||
Buffers: shared hit=60
|
||||
-> Index Scan using messages_history on messages m (actual time=0.019..0.222 rows=51 loops=1)
|
||||
Index Cond: ((chat_id = '7c307498-c398-4a1e-be96-13556a559cbf'::uuid) AND (ROW(created_at, id) > ROW('2026-09-01 02:46:40+00'::timestamp with time zone, '170ea586-3f7e-4314-a9bf-8e4f394941ac'::uuid)))
|
||||
Buffers: shared hit=60
|
||||
Limit (actual time=0.019..0.208 rows=51 loops=1)
|
||||
Buffers: shared hit=59
|
||||
-> Index Scan using messages_history on messages m (actual time=0.019..0.204 rows=51 loops=1)
|
||||
Index Cond: ((chat_id = '872415a3-3ab7-4e2b-bbc5-e5d03904fd1d'::uuid) AND (ROW(created_at, id) > ROW('2026-09-01 02:46:40+00'::timestamp with time zone, '4bd22867-547f-4ecf-8182-443fbb004188'::uuid)))
|
||||
Buffers: shared hit=59
|
||||
SubPlan 1
|
||||
-> Sort (actual time=0.003..0.003 rows=0 loops=51)
|
||||
-> Sort (actual time=0.002..0.002 rows=0 loops=51)
|
||||
Sort Key: a."position"
|
||||
Sort Method: quicksort Memory: 25kB
|
||||
Buffers: shared hit=54
|
||||
@@ -57,39 +57,44 @@
|
||||
Buffers: shared hit=51
|
||||
Planning:
|
||||
Buffers: shared hit=63
|
||||
Planning Time: 0.157 ms
|
||||
Execution Time: 0.242 ms
|
||||
Planning Time: 0.156 ms
|
||||
Execution Time: 0.225 ms
|
||||
|
||||
|
||||
=== 3. The same page with OFFSET 10000 (the app does NOT do this)
|
||||
QUERY PLAN
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Limit (actual time=0.878..0.884 rows=51 loops=1)
|
||||
Buffers: shared hit=258
|
||||
-> Index Scan using messages_history on messages (actual time=0.007..0.669 rows=10051 loops=1)
|
||||
Index Cond: (chat_id = '7c307498-c398-4a1e-be96-13556a559cbf'::uuid)
|
||||
Buffers: shared hit=258
|
||||
Planning Time: 0.037 ms
|
||||
Execution Time: 0.897 ms
|
||||
QUERY PLAN
|
||||
--------------------------------------------------------------------------------
|
||||
Limit (actual time=3.056..3.060 rows=51 loops=1)
|
||||
Buffers: shared hit=585
|
||||
-> Sort (actual time=2.647..2.857 rows=10051 loops=1)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: quicksort Memory: 2377kB
|
||||
Buffers: shared hit=585
|
||||
-> Seq Scan on messages (actual time=0.005..1.278 rows=15000 loops=1)
|
||||
Filter: (chat_id = '872415a3-3ab7-4e2b-bbc5-e5d03904fd1d'::uuid)
|
||||
Rows Removed by Filter: 20618
|
||||
Buffers: shared hit=585
|
||||
Planning Time: 0.033 ms
|
||||
Execution Time: 3.107 ms
|
||||
|
||||
|
||||
=== 4. Query 2 without the index (index is dropped only inside this transaction)
|
||||
QUERY PLAN
|
||||
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (actual time=1.097..1.101 rows=51 loops=1)
|
||||
Buffers: shared hit=261
|
||||
-> Sort (actual time=1.097..1.098 rows=51 loops=1)
|
||||
Limit (actual time=1.432..1.436 rows=51 loops=1)
|
||||
Buffers: shared hit=585
|
||||
-> Sort (actual time=1.432..1.433 rows=51 loops=1)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: top-N heapsort Memory: 31kB
|
||||
Buffers: shared hit=261
|
||||
-> Seq Scan on messages (actual time=0.307..0.737 rows=5000 loops=1)
|
||||
Filter: ((chat_id = '7c307498-c398-4a1e-be96-13556a559cbf'::uuid) AND (ROW(created_at, id) > ROW('2026-09-01 02:46:40+00'::timestamp with time zone, '170ea586-3f7e-4314-a9bf-8e4f394941ac'::uuid)))
|
||||
Rows Removed by Filter: 15146
|
||||
Buffers: shared hit=261
|
||||
Buffers: shared hit=585
|
||||
-> Seq Scan on messages (actual time=0.678..1.116 rows=5000 loops=1)
|
||||
Filter: ((chat_id = '872415a3-3ab7-4e2b-bbc5-e5d03904fd1d'::uuid) AND (ROW(created_at, id) > ROW('2026-09-01 02:46:40+00'::timestamp with time zone, '4bd22867-547f-4ecf-8182-443fbb004188'::uuid)))
|
||||
Rows Removed by Filter: 30618
|
||||
Buffers: shared hit=585
|
||||
Planning:
|
||||
Buffers: shared hit=4
|
||||
Planning Time: 0.051 ms
|
||||
Execution Time: 1.115 ms
|
||||
Planning Time: 0.049 ms
|
||||
Execution Time: 1.450 ms
|
||||
|
||||
|
||||
=== ROLLBACK: test data removed, index is back
|
||||
|
||||
Reference in New Issue
Block a user