This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
INSERT INTO users (id, username, display_name, password_hash, created_at)
|
||||
VALUES ('11111111-1111-1111-1111-111111111111', 'explain_test', 'Test', 'hash', NOW());
|
||||
|
||||
INSERT INTO chats (id, title, created_at)
|
||||
VALUES ('22222222-2222-2222-2222-222222222222', 'Explain Chat', NOW());
|
||||
|
||||
INSERT INTO messages (id, chat_id, sender_id, text, created_at)
|
||||
SELECT
|
||||
gen_random_uuid(),
|
||||
'22222222-2222-2222-2222-222222222222',
|
||||
'11111111-1111-1111-1111-111111111111',
|
||||
'Message ' || i,
|
||||
NOW() - (i || ' minutes')::interval
|
||||
FROM generate_series(1, 10000) AS i;
|
||||
|
||||
Команды для теста
|
||||
EXPLAIN (ANALYZE, BUFFERS)
|
||||
SELECT * FROM messages
|
||||
WHERE chat_id = '22222222-2222-2222-2222-222222222222'
|
||||
ORDER BY created_at, id
|
||||
LIMIT 50;
|
||||
Reference in New Issue
Block a user