Обновить доказательства на коде после ревью, сверить с ними отчёт и выделить исправления базы в шаблоне PR
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# EXPLAIN (ANALYZE, BUFFERS) of the history query: make explain
|
||||
# date: 2026-10-06T12:59:03Z, commit: 949622e (branch solution/bpi2301-bakulin)
|
||||
# date: 2026-10-21T12:09:10Z, commit: 7aa86d3 (branch solution/bpi2301-bakulin)
|
||||
# host: Windows 11, Docker Desktop 28.5.1 (4 CPU, 4111327232 bytes RAM), Go go1.27.1, Python 3.13.1
|
||||
|
||||
big_chat_messages | all_messages
|
||||
@@ -11,51 +11,51 @@
|
||||
== First page: no cursor, limit 50 (+1 row that tells whether a next page exists)
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=0.42..23.86 rows=51 width=67) (actual time=0.020..0.077 rows=51.00 loops=1)
|
||||
Limit (cost=0.42..23.92 rows=51 width=67) (actual time=0.027..0.060 rows=51.00 loops=1)
|
||||
Buffers: shared hit=51
|
||||
-> Index Scan using messages_pkey on messages (cost=0.42..5535.89 rows=12045 width=67) (actual time=0.018..0.072 rows=51.00 loops=1)
|
||||
Index Cond: ((chat_id = '01a1114d-de5d-7f2e-8176-990d37b9797e'::uuid) AND (id > '00000000-0000-0000-0000-000000000000'::uuid))
|
||||
-> Index Scan using messages_pkey on messages (cost=0.42..5526.02 rows=11988 width=67) (actual time=0.026..0.056 rows=51.00 loops=1)
|
||||
Index Cond: ((chat_id = '01a15e5f-93aa-7f38-9ff3-684f0d6ded77'::uuid) AND (id > '00000000-0000-0000-0000-000000000000'::uuid))
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=51
|
||||
Planning:
|
||||
Buffers: shared hit=17
|
||||
Planning Time: 0.327 ms
|
||||
Execution Time: 0.101 ms
|
||||
Planning Time: 0.211 ms
|
||||
Execution Time: 0.097 ms
|
||||
(10 rows)
|
||||
|
||||
|
||||
== Deep page: cursor after the 10 001st message of the chat
|
||||
QUERY PLAN
|
||||
----------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=0.42..185.00 rows=51 width=67) (actual time=0.021..0.033 rows=51.00 loops=1)
|
||||
Limit (cost=0.42..184.60 rows=51 width=67) (actual time=0.018..0.030 rows=51.00 loops=1)
|
||||
Buffers: shared hit=6
|
||||
-> Index Scan using messages_pkey on messages (cost=0.42..655.49 rows=181 width=67) (actual time=0.020..0.029 rows=51.00 loops=1)
|
||||
Index Cond: ((chat_id = '01a1114d-de5d-7f2e-8176-990d37b9797e'::uuid) AND (id > '01a1114d-e03e-797e-bdd0-3cb5b8cb3079'::uuid))
|
||||
-> Index Scan using messages_pkey on messages (cost=0.42..650.48 rows=180 width=67) (actual time=0.018..0.026 rows=51.00 loops=1)
|
||||
Index Cond: ((chat_id = '01a15e5f-93aa-7f38-9ff3-684f0d6ded77'::uuid) AND (id > '01a15e5f-9557-7527-8fb0-c493cb1229d4'::uuid))
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=6
|
||||
Planning Time: 0.093 ms
|
||||
Execution Time: 0.050 ms
|
||||
Planning Time: 0.071 ms
|
||||
Execution Time: 0.047 ms
|
||||
(8 rows)
|
||||
|
||||
|
||||
== For contrast, OFFSET pagination of the same page reads every skipped row
|
||||
QUERY PLAN
|
||||
-----------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=2837.94..2838.07 rows=51 width=67) (actual time=4.491..4.496 rows=51.00 loops=1)
|
||||
Limit (cost=2832.42..2832.54 rows=51 width=67) (actual time=6.369..6.376 rows=51.00 loops=1)
|
||||
Buffers: shared hit=495
|
||||
-> Sort (cost=2812.94..2843.06 rows=12047 width=67) (actual time=3.874..4.232 rows=10052.00 loops=1)
|
||||
-> Sort (cost=2807.41..2837.39 rows=11989 width=67) (actual time=5.728..6.109 rows=10052.00 loops=1)
|
||||
Sort Key: id
|
||||
Sort Method: quicksort Memory: 1978kB
|
||||
Buffers: shared hit=495
|
||||
-> Bitmap Heap Scan on messages (cost=585.78..1996.37 rows=12047 width=67) (actual time=0.422..1.796 rows=12000.00 loops=1)
|
||||
Recheck Cond: (chat_id = '01a1114d-de5d-7f2e-8176-990d37b9797e'::uuid)
|
||||
-> Bitmap Heap Scan on messages (cost=585.33..1995.19 rows=11989 width=67) (actual time=0.717..2.712 rows=12000.00 loops=1)
|
||||
Recheck Cond: (chat_id = '01a15e5f-93aa-7f38-9ff3-684f0d6ded77'::uuid)
|
||||
Heap Blocks: exact=363
|
||||
Buffers: shared hit=495
|
||||
-> Bitmap Index Scan on messages_pkey (cost=0.00..582.77 rows=12047 width=0) (actual time=0.386..0.386 rows=12000.00 loops=1)
|
||||
Index Cond: (chat_id = '01a1114d-de5d-7f2e-8176-990d37b9797e'::uuid)
|
||||
-> Bitmap Index Scan on messages_pkey (cost=0.00..582.34 rows=11989 width=0) (actual time=0.672..0.673 rows=12000.00 loops=1)
|
||||
Index Cond: (chat_id = '01a15e5f-93aa-7f38-9ff3-684f0d6ded77'::uuid)
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=132
|
||||
Planning Time: 0.043 ms
|
||||
Execution Time: 4.629 ms
|
||||
Planning Time: 0.041 ms
|
||||
Execution Time: 6.524 ms
|
||||
(16 rows)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user