diff --git a/evidence/chat_ids.txt b/evidence/chat_ids.txt new file mode 100644 index 0000000..075a107 --- /dev/null +++ b/evidence/chat_ids.txt @@ -0,0 +1,4 @@ +hot=349f1aef-3bbc-42d1-8724-e8d22b8c2253 +medium-1=532a232a-4038-4d2a-96dd-e5c901e868a2 +small-1=950e3367-500a-43b3-b824-b5cf521839b9 +tiny-1=c099542c-e3c2-49ff-ab10-5389ed2450af diff --git a/evidence/explain_history.txt b/evidence/explain_history.txt index 8f2a0c0..65caa04 100644 --- a/evidence/explain_history.txt +++ b/evidence/explain_history.txt @@ -1,19 +1,19 @@ # EXPLAIN (ANALYZE, BUFFERS) для истории сообщений -# date: 2026-10-02T11:01:11Z -# chat_id: cf9e8ca9-d08c-41d1-b55f-18c9fba43aec +# date: 2026-10-02T11:28:14Z +# chat_id: 349f1aef-3bbc-42d1-8724-e8d22b8c2253 ## Ключевой запрос пагинации - QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------ - Limit (cost=0.29..4.38 rows=50 width=73) (actual time=0.021..0.029 rows=50 loops=1) - Buffers: shared hit=3 - -> Index Scan using messages_chat_created_id_idx on messages (cost=0.29..819.43 rows=10000 width=73) (actual time=0.020..0.025 rows=50 loops=1) - Index Cond: (chat_id = 'cf9e8ca9-d08c-41d1-b55f-18c9fba43aec'::uuid) - Buffers: shared hit=3 + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------ + Limit (cost=0.42..8.05 rows=50 width=69) (actual time=0.025..0.042 rows=50 loops=1) + Buffers: shared hit=45 + -> Index Scan using messages_chat_created_id_idx on messages (cost=0.42..8419.02 rows=55133 width=69) (actual time=0.024..0.038 rows=50 loops=1) + Index Cond: (chat_id = '349f1aef-3bbc-42d1-8724-e8d22b8c2253'::uuid) + Buffers: shared hit=45 Planning: - Buffers: shared hit=111 - Planning Time: 0.694 ms - Execution Time: 0.063 ms + Buffers: shared hit=109 + Planning Time: 0.611 ms + Execution Time: 0.064 ms (9 rows) @@ -28,6 +28,6 @@ ## Оценка размера и количества estimated_rows | total_size ----------------+------------ - 10222 | 2264 kB + 110222 | 25 MB (1 row) diff --git a/evidence/explain_history_10k.txt b/evidence/explain_history_10k.txt new file mode 100644 index 0000000..8f2a0c0 --- /dev/null +++ b/evidence/explain_history_10k.txt @@ -0,0 +1,33 @@ +# EXPLAIN (ANALYZE, BUFFERS) для истории сообщений +# date: 2026-10-02T11:01:11Z +# chat_id: cf9e8ca9-d08c-41d1-b55f-18c9fba43aec + +## Ключевой запрос пагинации + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------------- + Limit (cost=0.29..4.38 rows=50 width=73) (actual time=0.021..0.029 rows=50 loops=1) + Buffers: shared hit=3 + -> Index Scan using messages_chat_created_id_idx on messages (cost=0.29..819.43 rows=10000 width=73) (actual time=0.020..0.025 rows=50 loops=1) + Index Cond: (chat_id = 'cf9e8ca9-d08c-41d1-b55f-18c9fba43aec'::uuid) + Buffers: shared hit=3 + Planning: + Buffers: shared hit=111 + Planning Time: 0.694 ms + Execution Time: 0.063 ms +(9 rows) + + +## Индексы таблицы messages + indexname | indexdef +------------------------------+---------------------------------------------------------------------------------------------------- + messages_pkey | CREATE UNIQUE INDEX messages_pkey ON public.messages USING btree (id) + messages_chat_created_id_idx | CREATE INDEX messages_chat_created_id_idx ON public.messages USING btree (chat_id, created_at, id) +(2 rows) + + +## Оценка размера и количества + estimated_rows | total_size +----------------+------------ + 10222 | 2264 kB +(1 row) + diff --git a/evidence/seed_large.txt b/evidence/seed_large.txt new file mode 100644 index 0000000..009ee8a --- /dev/null +++ b/evidence/seed_large.txt @@ -0,0 +1,31 @@ +hot: 55000 сообщений за 61.7s (891/s) +medium-1: 10000 сообщений за 11.4s (879/s) +medium-2: 10000 сообщений за 11.4s (879/s) +medium-3: 10000 сообщений за 11.7s (854/s) +small-1: 1000 сообщений за 1.3s (781/s) +small-2: 1000 сообщений за 1.2s (800/s) +small-3: 1000 сообщений за 1.2s (820/s) +small-4: 1000 сообщений за 1.3s (790/s) +small-5: 1000 сообщений за 1.2s (810/s) +small-6: 1000 сообщений за 1.2s (820/s) +small-7: 1000 сообщений за 1.3s (791/s) +small-8: 1000 сообщений за 1.2s (810/s) +small-9: 1000 сообщений за 1.2s (820/s) +small-10: 1000 сообщений за 1.2s (810/s) +tiny-1: 500 сообщений за 0.7s (761/s) +tiny-2: 500 сообщений за 0.7s (761/s) +tiny-3: 500 сообщений за 0.7s (762/s) +tiny-4: 500 сообщений за 0.6s (780/s) +tiny-5: 500 сообщений за 0.6s (800/s) +tiny-6: 500 сообщений за 0.7s (762/s) +tiny-7: 500 сообщений за 0.6s (781/s) +tiny-8: 500 сообщений за 0.7s (744/s) +tiny-9: 500 сообщений за 0.7s (728/s) +tiny-10: 500 сообщений за 0.7s (762/s) + +Всего 100000 сообщений за 115.5s (866/s) +chat_id для EXPLAIN: + hot: 349f1aef-3bbc-42d1-8724-e8d22b8c2253 + medium-1: 532a232a-4038-4d2a-96dd-e5c901e868a2 + small-1: 950e3367-500a-43b3-b824-b5cf521839b9 + tiny-1: c099542c-e3c2-49ff-ab10-5389ed2450af \ No newline at end of file