| ▲ | crazygringo 5 hours ago | |
I'm genuinely surprised that there isn't column-level shared-dictionary string compression built into SQLite, MySQL/MariaDB or Postgres, like this post is describing. SQLite has no compression support, MySQL/MariaDB have page-level compression which doesn't work great and I've never seen anyone enable in production, and Postgres has per-value compression which is good for extremely long strings, but useless for short ones. There are just so many string columns where values and substrings get repeated so much, whether you're storing names, URL's, or just regular text. And I have databases I know would be reduced in size by at least half. Is it just really really hard to maintain a shared dictionary when constantly adding and deleting values? Is there just no established reference algorithm for it? It still seems like it would be worth it even if it were something you had to manually set. E.g. wait until your table has 100,000 values, build a dictionary from those, and the dictionary is set in stone and used for the next 10,000,000 rows too unless you rebuild it in the future (which would be an expensive operation). | ||
| ▲ | ww520 2 hours ago | parent | next [-] | |
Strings in textual index are already compressed, with common prefix compression or other schemes. They are perfectly queryable. Not sure if their compression scheme is for index or data columns. Global column dictionary has more complexity than normal. Now you are touching more pages than just the index pages and data page. The dictionary entries are sorted, so you need to worry about page expansion and contraction. They sidestep the problems by making it immutable, presumably building it up front by scanning all the data. Not sure why using FSST is better than using a standard compression algorithm to compress the dictionary entries. Storing the strings themselves as dictionary IDs is a good idea, as they can be processed quickly with SIMD. | ||
| ▲ | hinkley 4 hours ago | parent | prev | next [-] | |
There are some databases that can move an entire column into the index. But that's mostly going to work for schemas where the number of distinct values is <<< rowcount, so that you're effectively interning the rows. | ||
| ▲ | pstuart 38 minutes ago | parent | prev | next [-] | |
Duckdb can also handle SQLite files: https://duckdb.org/docs/stable/core_extensions/sqlite | ||
| ▲ | analyst74 4 hours ago | parent | prev [-] | |
compression is not free, dictionary compression: 1, complicates and slows down update, which is typically more important in OLTP than OLAP 2, is generally bad for high cardinality columns, which requires tracking cardinality to make decisions, which further complicates things. lastly, additional operational complexity (like the table maintenance system you described in last paragraph) could reduce system reliability, and they might decide it's not worth the price or against their philosophy. | ||