feat(research) grade 5 assignment done

This commit is contained in:
imadev
2026-11-05 23:52:34 +03:00
parent 71174f844c
commit 31194c0419
10 changed files with 651 additions and 4 deletions
+22
View File
@@ -0,0 +1,22 @@
# Index experiment
Dataset: 300000 messages, 5000 chats, 2000 users.
Median of 5 warm-cache runs; plan is the sequence of access nodes.
| state | query | median ms | plan |
| --- | --- | ---: | --- |
| both | user_chats | 1.379 | Sort>Hash Join>Seq Scan>Index Only Scan |
| both | chat_messages | 0.428 | Index Scan |
| both | user_feed | 35.396 | Sort>Nested Loop>Index Only Scan>Index Scan |
| messages_only | user_chats | 7.360 | Sort>Hash Join>Seq Scan |
| messages_only | chat_messages | 0.469 | Index Scan |
| messages_only | user_feed | 35.218 | Sort>Nested Loop>Seq Scan>Index Scan |
| membership_only | user_chats | 1.402 | Sort>Hash Join>Seq Scan>Index Only Scan |
| membership_only | chat_messages | 57.634 | Sort>Seq Scan |
| membership_only | user_feed | 80.404 | Sort>Hash Join>Seq Scan>Index Only Scan |
Index sizes after restoring both:
chat_members_user_idx=3536 kB, messages_chat_created_id_idx=17 MB, messages_table=75 MB
pgbench message-like inserts, 4 clients, 10 s: with messages index 2718.889742 tps; without 2640.028063 tps.
The research DB is left with both indexes.
+4
View File
@@ -0,0 +1,4 @@
messages,dump_s,restore_s,dump_bytes,db_bytes,table_bytes,index_bytes
100000,1.02,1.44,5109980,47411683,26402816,9535488
200000,1.92,2.36,9803565,74240483,53231616,15417344
300000,2.66,3.28,14500027,99627491,78618624,21307392
1 messages dump_s restore_s dump_bytes db_bytes table_bytes index_bytes
2 100000 1.02 1.44 5109980 47411683 26402816 9535488
3 200000 1.92 2.36 9803565 74240483 53231616 15417344
4 300000 2.66 3.28 14500027 99627491 78618624 21307392
+9
View File
@@ -0,0 +1,9 @@
| messages | dump s | restore s | dump MiB | DB MiB | lost msgs at 878 RPS |
| ---: | ---: | ---: | ---: | ---: | ---: |
| 100000 | 1.02 | 1.44 | 4.9 | 45.2 | 896 |
| 200000 | 1.92 | 2.36 | 9.3 | 70.8 | 1686 |
| 300000 | 2.66 | 3.28 | 13.8 | 95.0 | 2335 |
dump: t = 0.227 + 8.200 * (messages / 1M) s, R^2=0.997
restore: t = 0.520 + 9.200 * (messages / 1M) s, R^2=1.000
dump+restore: t = 0.747 + 17.400 * (messages / 1M) s, R^2=0.999