Files
mtusi2026lab6/student-tests/plans.sql
T

17 lines
662 B
PL/PgSQL

-- Repeat the same read and rolled-back write three times for each index.
SELECT 'EXPLAIN (ANALYZE,BUFFERS,FORMAT JSON)
SELECT id,chat_id,sender_id,text,created_at FROM messages
WHERE chat_id=md5(''1'')::uuid
AND (created_at,id)>(''2026-01-01Z''::timestamptz+85000*interval ''1 microsecond'',md5(''85000'')::uuid)
ORDER BY created_at,id LIMIT 51;
BEGIN;
EXPLAIN (ANALYZE,BUFFERS,FORMAT JSON)
INSERT INTO messages
SELECT md5(n::text)::uuid,md5(''1'')::uuid,
''11111111-1111-4111-8111-111111111111'',''new-synthetic-''||n,
''2026-01-01Z''::timestamptz+n*interval ''1 microsecond''
FROM generate_series(100001,101000) n;
ROLLBACK;'
FROM generate_series(1,3)
\gexec