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,36 @@
|
||||
\set ON_ERROR_STOP on
|
||||
\timing on
|
||||
|
||||
SELECT chat_id
|
||||
FROM messages
|
||||
GROUP BY chat_id
|
||||
ORDER BY COUNT(*) DESC
|
||||
LIMIT 1
|
||||
\gset
|
||||
|
||||
\echo 'COMPOSITE INDEX'
|
||||
|
||||
EXPLAIN (ANALYZE, BUFFERS)
|
||||
SELECT id, text, created_at
|
||||
FROM messages
|
||||
WHERE chat_id = :'chat_id'
|
||||
ORDER BY created_at, id
|
||||
LIMIT 50;
|
||||
|
||||
BEGIN;
|
||||
CREATE INDEX IF NOT EXISTS idx_messages_chat_id_only ON messages (chat_id);
|
||||
|
||||
DROP INDEX IF EXISTS idx_messages_chat_created_id;
|
||||
|
||||
\echo 'SINGLE COLUMN INDEX'
|
||||
|
||||
EXPLAIN (ANALYZE, BUFFERS)
|
||||
SELECT id, text, created_at
|
||||
FROM messages
|
||||
WHERE chat_id = :'chat_id'
|
||||
ORDER BY created_at, id
|
||||
LIMIT 50;
|
||||
|
||||
ROLLBACK;
|
||||
|
||||
\echo 'ORIGINAL INDEX RESTORED'
|
||||
Reference in New Issue
Block a user