This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
|
||||
\set ON_ERROR_STOP on
|
||||
|
||||
\echo '=== Row counts by table ==='
|
||||
|
||||
SELECT 'messages' AS table_name, COUNT(*) AS rows_count
|
||||
FROM messages
|
||||
UNION ALL
|
||||
SELECT 'bench_index_a', COUNT(*) FROM bench_index_a
|
||||
UNION ALL
|
||||
SELECT 'bench_index_b', COUNT(*) FROM bench_index_b
|
||||
ORDER BY table_name;
|
||||
|
||||
\echo '=== Message distribution by chat ==='
|
||||
|
||||
SELECT
|
||||
chat_id,
|
||||
COUNT(*) AS message_count
|
||||
FROM messages
|
||||
GROUP BY chat_id
|
||||
ORDER BY chat_id;
|
||||
|
||||
\echo '=== Deterministic sample of messages ==='
|
||||
|
||||
SELECT
|
||||
id,
|
||||
chat_id,
|
||||
sender_id,
|
||||
text,
|
||||
created_at
|
||||
FROM messages
|
||||
ORDER BY id
|
||||
LIMIT 10;
|
||||
|
||||
\echo '=== Message content checksum ==='
|
||||
|
||||
SELECT
|
||||
COUNT(*) AS message_count,
|
||||
md5(
|
||||
string_agg(
|
||||
md5(
|
||||
id::text || '|' ||
|
||||
chat_id::text || '|' ||
|
||||
sender_id::text || '|' ||
|
||||
length(text)::text || ':' || text || '|' ||
|
||||
to_char(
|
||||
created_at AT TIME ZONE 'UTC',
|
||||
'YYYY-MM-DD"T"HH24:MI:SS.US'
|
||||
)
|
||||
),
|
||||
''
|
||||
ORDER BY id
|
||||
)
|
||||
) AS content_checksum
|
||||
FROM messages;
|
||||
Reference in New Issue
Block a user