Implement messenger functionality
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
2026-10-30 16:12:37 +03:00
parent 65003b6119
commit add9fbb9f4
15 changed files with 986 additions and 32 deletions
+23
View File
@@ -0,0 +1,23 @@
BEGIN;
CREATE TEMP TABLE lab_messages (
id UUID NOT NULL,
chat_id INTEGER NOT NULL,
created_at TIMESTAMPTZ NOT NULL,
text VARCHAR(4000) NOT NULL
);
CREATE INDEX lab_messages_history_idx ON lab_messages(chat_id, created_at, id);
INSERT INTO lab_messages(id, chat_id, created_at, text)
SELECT md5(g::text)::uuid,
CASE WHEN g <= 10000 THEN 1 ELSE 2 + (g % 100) END,
TIMESTAMPTZ '2026-01-01 00:00:00+00' + g * INTERVAL '1 millisecond',
repeat('x', 40)
FROM generate_series(1, 100000) AS g;
ANALYZE lab_messages;
EXPLAIN (ANALYZE, BUFFERS)
SELECT id, chat_id, created_at, text
FROM lab_messages
WHERE chat_id = 1
AND (created_at, id) > (TIMESTAMPTZ '2026-01-01 00:00:05+00', md5('5000')::uuid)
ORDER BY created_at, id
LIMIT 50;
ROLLBACK;