0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-07 13:19:19 +08:00
discourse/migrations/tooling
Gerhard Schlager a0b7033f31 MT: Add id storage benchmark comparing TEXT and BLOB keys
Part of the uploads rework. The IntermediateDB derives upload ids by
hashing (XXH3-128) because uploads have no natural id, and those ids
end up in the table's PK and in every *upload*_id reference column. I
wanted actual numbers on whether storing the hash as a 16-byte BLOB
instead of the current 24-char base64 TEXT is worth it before building
more on top of the current format.

It is. Full run (5M sources, 20M references, 4-shard merge,
i9-13900H/NVMe):

    metric                    TEXT        BLOB     delta
    source insert rows/s     74675       83442    +11.7%
    ref insert rows/s      1244109     1422542    +14.3%
    point lookups/s         207467      301823    +45.5%
    join s                   22.73       21.33     -6.1%
    shard merge s            21.44       19.43     -9.3%
    db file size            1.7 GB      1.3 GB    -22.6%

Nothing gets slower - the gain is pure key width in the PK b-tree and
every reference index, and it bites twice in the shard-merge path
(table + index). The trade-off is ergonomics: ids stop being readable
in query output and ad-hoc SQL needs hex(id) / x'...' literals.

The script mirrors the converter's write path (prepared statements,
batched transactions, same pragmas) and is parameterized via env vars;
results are recorded in RESULTS.md.
2026-07-10 20:50:04 +02:00
..
config/schema MT: Keep the real created_at for category moderation groups 2026-07-06 10:58:15 +02:00
lib MT: Let a generated model declare its conflict strategy in the schema DSL 2026-07-03 17:05:25 +02:00
scripts MT: Add id storage benchmark comparing TEXT and BLOB keys 2026-07-10 20:50:04 +02:00
spec MT: Let a generated model declare its conflict strategy in the schema DSL 2026-07-03 17:05:25 +02:00
.rspec
Gemfile
migrations-tooling.gemspec