Twins by content: type the hash as the column
Test and deploy / test (push) Successful in 3m49s
Test and deploy / deploy (push) Successful in 1m5s

jsonb_to_recordset declared hash16k as text; against the char(32) column the join
cast the column, so Postgres scanned all of file_hashes for every call (4 s, 20
calls a minute: 44% of the database's time). Declared char(32), the join walks
file_hashes_hash_size_release_idx: 24 ms for 300 pairs. LOG.md (138).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Daan MeijerandClaude Fable 5.1 committed 2026-11-04 09:31:06 +01:00
1 parent d7171a5ca4
commit f537add573
1 file changed
+3 -1
+3 -1
View File
@@ -11,9 +11,11 @@ export async function twinNames(
): Promise<Map<string, string>> { ): Promise<Map<string, string>> {
const out = new Map<string, string>() const out = new Map<string, string>()
if (pairs.length === 0) return out if (pairs.length === 0) return out
// hash16k typed as the column (char(32)): as text the join cast the column and scanned all of file_hashes
// instead of file_hashes_hash_size_release_idx, 4 s a call (LOG.md (138)).
const { rows } = await trx.rawQuery( const { rows } = await trx.rawQuery(
`SELECT DISTINCT ON (h.hash16k, h.size) h.hash16k, h.size, coalesce(r.inner_name, r.name) AS name `SELECT DISTINCT ON (h.hash16k, h.size) h.hash16k, h.size, coalesce(r.inner_name, r.name) AS name
FROM jsonb_to_recordset(?::jsonb) AS v(hash16k text, size bigint) FROM jsonb_to_recordset(?::jsonb) AS v(hash16k char(32), size bigint)
JOIN file_hashes h ON h.hash16k = v.hash16k AND h.size = v.size JOIN file_hashes h ON h.hash16k = v.hash16k AND h.size = v.size
JOIN releases r ON r.id = h.release_id AND (r.readable OR r.inner_name IS NOT NULL) JOIN releases r ON r.id = h.release_id AND (r.readable OR r.inner_name IS NOT NULL)
WHERE NOT EXISTS (SELECT 1 FROM release_verdicts x WHERE x.release_id = r.id) WHERE NOT EXISTS (SELECT 1 FROM release_verdicts x WHERE x.release_id = r.id)