31 comments

  • cryptonector 4 hours ago

    ^F intern -> not found.

    But string interning is what they're doing, isn't it?

    > Dictionary compression is a well-known and widely applied technique. The basic idea is that you store all the unique input values within a dictionary, and then you compress the input by substituting the input values with smaller fixed-size integer keys that act as offsets into the dictionary. Building a CedarDB dictionary on our input data and compressing the data would look like this:

    That's string interning!!

    Is interning just too old a concept now and it has to be rediscovered/reinvented and renamed?

    • masklinn 2 hours ago

      String interning only stores whole strings, dictionary compression stores substrings. Essentially string interning is a trivial subset of dictionary compression (because you don’t need a substringing scheme, which is the hard part).

    • snackbroken an hour ago

      Doesn't interning usually refer to when you only consider identical copies, as opposed to dictionary compression where you allow for concatenations? E.g.

        Interning:
        1: "foo"
        2: "bar"
      
        my_string = "foo" // stored as ref->1
        my_other_string = "foobarbaz" // not found & too long to get interned, stored as "foobarbaz"
      
        Dictionary compression:
        1: "foo"
        2: "bar"
        
        my_string = "foo" // stored as ref->1
        my_other_string = "foobarbaz" // stored as ref->1,ref->2,"baz" (or ref->1,ref->2,ref->3 and "baz" is added to the dict)
    • 0928374082 4 hours ago

      > rediscovered/reinvented and renamed

      It's not old yet; it'll be old once it's been renamed two or three times...

  • crazygringo 11 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).

    • andersmurphy an hour ago

      In the case of sqlite you can just use ZFS and get page level compression.

    • ww520 8 hours ago

      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.

      • randomuser47 3 hours ago

        > Not sure why using FSST is better than using a standard compression algorithm to compress the dictionary entries.

        I believe the reason is that FSST allows access to individual strings in the compressed corpus, which is required for fast random access. This is more important for OLTP than OLAP, I assume. More standard compression algorithms, such as zstd, might decompress very fast, but I don't think they allow that

    • hinkley 10 hours ago

      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.

    • groundzeros2015 5 hours ago

      How do you layout all that variable length data in memory m?

    • analyst74 10 hours ago

      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.

    • pstuart 6 hours ago

      Duckdb can also handle SQLite files: https://duckdb.org/docs/stable/core_extensions/sqlite

  • ayuhito 10 hours ago

    DuckDB has one of my favourite articles on this topic if you want something a little more high level: https://duckdb.org/2022/10/28/lightweight-compression

  • cespare 5 hours ago

    This scheme reminds me of smaz (https://github.com/antirez/smaz) but with dynamically generated dictionaries.

  • stephantul 3 hours ago

    The compression algorithm is very similar to a greedy subword tokenizer, which is used in BERT and other older language models, but has become less popular in favor of BPE.

  • lor_louis 8 hours ago

    I've implemented a similar system based on the original 2020 paper, but we applied it to the text log to try to "extract" similar features from free-form text. It looked promising and even supported full regex search, but the work was ultimately abandoned when we got acquired.

  • vismit2000 8 hours ago
  • mbfg 13 hours ago

    I wonder how one does like queries.

    • hcs 12 hours ago

      After decompression, with the performance characteristics you'd expect. If it has to come off disk it's still a win or at least usually breaks even in their measurements. https://cedardb.com/blog/string_compression/#query-runtime

      The paper suggests that you could rework string matching to work on the compressed data but they haven't done it.

    • speed_spread 12 hours ago

      s, jst cmprss ll qrs b rmvng vyls!

  • vivzkestrel 6 hours ago

    pardon my stupid question, what does cedardb do that postgres, duckdb, cassandra and the 758452758421 databases that came before dont?

  • ForHackernews 13 hours ago

    Never heard of CedarDB.

    Seems to be another commercial cloud-hosted thing offering a Postgres API? https://dbdb.io/db/cedardb

    https://cedardb.com/blog/ode_to_postgres/

    • switz 12 hours ago

      I was evaluating it recently but it's not FOSS, so buyer beware. I'm totally fine with commercialization, but I hesitate to build on top of data stores with no escape hatches or maintenance plans–especially when they're venture backed. It is self-hostable, but not OSS.

    • cmrdporcupine 12 hours ago

      It's a startup founded by -- and built with tech coming out of research by -- some well known people in the DB research community.

      Successor to Umbra, I believe.

      I know somebody (quite talented) working there. It's likely to kick ass in terms of performance.

      But it's hard to get people to pay for a DB these days.

      • atombender 10 hours ago

        It's probably going to be acquired. The last effort to commercialize the TUM (Technical University of Munich) database group's work was acquired by Snowflake and disappeared into that stack.

        CedarDB is the commercialization of Umbra, the TUM group's in-memory database lead by professor Thomas Neumann. Umbra is a successor to HyPer, so this is the third generation of the system Neumann came up with.

        Umbra/CedarDB isn't a completely new way of doing database stuff, but basically a combination of several things that rearchitect the query engine from the ground up for modern systems: A query compiler that generates native code, a buffer pool manager optimized for multi core, push-based DAG execution that divides work into batches ("morsels"), and in-memory Adaptive Radix Tries (never used in a database before, I think).

        It also has an advanced query planner that embraces the latest theoretical advances in query optimization, especially some techniques to unnest complex multi-join query plans, especially with queries that have a ton of joins. The TUM group has published some great papers on this.

        • Sesse__ 2 hours ago

          > It also has an advanced query planner that embraces the latest theoretical advances in query optimization, especially some techniques to unnest complex multi-join query plans, especially with queries that have a ton of joins. The TUM group has published some great papers on this.

          I always wondered how good these planners are in practice. The Neumann/Moerkotte papers are top notch (I've implemented several of them myself), but a planner is much more than its theoretical capabilities; you need so much tweaking and tuning to make anything work well, especially in the cost model. Does anyone have any Umbra experience and can say how well it works for things that are not DBT-3?

        • senderista 9 hours ago

          Umbra is not an in-memory database (Hyper was). TUM gave up on the feasibility of in-memory databases several years ago (when the price of RAM relative to storage stopped falling).

          • cmrdporcupine 9 hours ago

            Yeah I think the way Umbra was pitched when I watched the talks and read the paper was as more as "hybrid" in the sense that it aimed for something close to in-memory performance while optimizing the page-in/page-out performance profile.

            The part of Umbra I found interesting was the buffer pool, so that's where focused most of my attention when reading though.

        • senderista 9 hours ago

          Are you thinking of Hyper being acquired by Tableau?

  • semiinfinitely 7 hours ago

    its a lesser-know fact that LLMs are SOTA at lossless string compression

    • boulos 4 hours ago

      This isn't strictly correct: you probably mean wrt compressed size. Compression is a tradeoff between size reduction and compression and decompression speed. So while things like Bellard's tz_zip (https://bellard.org/ts_zip/) or nncp compress really well they are extremely slow compared to say zstd or the much faster compression scheme in the article. It's a totally different class of codec.