feat: implement persistent messenger with PostgreSQL and Redis
Skeleton contracts / contracts (pull_request) Canceled after 0s
Skeleton contracts / contracts (pull_request) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
\set ON_ERROR_STOP on
|
||||
\timing on
|
||||
|
||||
BEGIN;
|
||||
|
||||
DROP INDEX IF EXISTS idx_messages_chat_created_id;
|
||||
DROP INDEX IF EXISTS idx_messages_chat_id_only;
|
||||
|
||||
\echo 'WRITE WITHOUT SECONDARY INDEXES'
|
||||
|
||||
EXPLAIN (ANALYZE, BUFFERS)
|
||||
INSERT INTO messages (id, chat_id, sender_id, text)
|
||||
SELECT
|
||||
gen_random_uuid(),
|
||||
c.id,
|
||||
c.created_by,
|
||||
'Write benchmark without index'
|
||||
FROM chats c
|
||||
CROSS JOIN generate_series(1, 10000)
|
||||
LIMIT 10000;
|
||||
|
||||
ROLLBACK;
|
||||
|
||||
BEGIN;
|
||||
CREATE INDEX IF NOT EXISTS idx_messages_chat_id_only ON messages (chat_id);
|
||||
|
||||
\echo 'WRITE WITH EXISTING INDEXES'
|
||||
|
||||
EXPLAIN (ANALYZE, BUFFERS)
|
||||
INSERT INTO messages (id, chat_id, sender_id, text)
|
||||
SELECT
|
||||
gen_random_uuid(),
|
||||
c.id,
|
||||
c.created_by,
|
||||
'Write benchmark with index'
|
||||
FROM chats c
|
||||
CROSS JOIN generate_series(1, 10000)
|
||||
LIMIT 10000;
|
||||
|
||||
ROLLBACK;
|
||||
Reference in New Issue
Block a user