• Hacker News
  • new|
  • comments|
  • show|
  • ask|
  • jobs|
  • JEONSEWON 4 days

    [flagged]

  • Vadim_samokhin 4 days

    Just in case, there is a btree_gin extension which can be used in queries combining gin-indexable column and btree-indexable column. It doesn’t solve top-K ordering problem though.

  • bbshfishe 4 days

    [dead]

  • ajstars 3 days

    Curious whether you benchmarked against a partial index on the sort column. For fixed-category top-K queries the planner sometimes picks it over a full index scan, though I've seen it regress on high-write tables due to index bloat. Did write volume factor into your test setup?

  • davidelettieri 4 days

    The "But Wait, We Need Filters Too" paragraph mentions "US" filter which is introduced only later on.

    GrayShade 4 days

    And footnote 3 is unreferenced.

    philippemnoel 3 days

    Good catch, thank you both -- fixed!

  • h1fra 3 days

    Postgres is really good at a lot of things, but it's very unfortunate that it's really bad at simple analytics. I wish there was a plugin instead of having to have N databases

    esafak 3 days

    ParadeDB is a pair of postgres plugins.

    philippemnoel 3 days

    (ParadeDB maintainer here) Yes! We've already built some faster analytics in Postgres, and have a lot more coming. Here's some relevant context in case you're curious: https://www.paradedb.com/blog/faceting

  • jmgimeno 4 days

    Maybe I'm wrong, but for this query:

    SELECT * FROM benchmark_logs WHERE severity < 3 ORDER BY timestamp DESC LIMIT 10;

    this index

    CREATE INDEX ON benchmark_logs (severity, timestamp);

    cannot be used as proposed: "Postgres can jump directly to the portion of the tree matching severity < 3 and then walk the timestamps in descending order to get the top K rows."

    Postgres with this index can walk to a part of the tree with severity < 3, but timestamps are sorted only for the same severity.

    Tostino 3 days

    Do a partial index on just timestamp where severity < 3 instead.

    Cervisia 3 days

    The SQLite documentation explains how (and how well) this works: https://www.sqlite.org/optoverview.html#the_skip_scan_optimi...

    igorw 3 days

    While Postgres did introduce skip scan in 18, it only works for equality matching: https://www.crunchydata.com/blog/get-excited-about-postgres-...

    dragon96 4 days

    If severity is a low cardinality enum, it still seems acceptable

    mattashii 3 days

    The order returned from the Index Scan is not the ordering requested by the user, so there would still have to be a full (or topk) Sort over the dataset returned from the index scan, which could negate the gains you get from using an Index Scan; PostgreSQL itself does not produce merge join plans that merge a spread of index scans to get suffix-ordered data out of an index.

  • tacone 4 days

    The issue here is the row based format. You simply can't filter on arbitrary columns with that. Either use an external warehouse or a columnar plug-in like Timescale.

    3 days

    hrmtst93837 3 days

    Columnar solves some query patterns but treating row format as a dealbreaker for top-k is an overreach. For modest-to-mid datasets with the right index Postgres handles top-k on composite keys well, especially if reads aren't scanning millions of rows or you can fit hot columns in memory.

    If latency really matters and you are working with large datasets, columnar extensions help, but they come with operational overhead and can limit transactional features, so it's usually better to stick with row-based unless you have a clear need.

    tacone 2 days

    My apologies, the article was talking about 100M-rows datasets so I presumed that was the scenario.

  • bob1029 4 days

    Lucene really does feel like magic sometimes. It was designed expressly to solve the top K problem at hyper scale. It's incredibly mature technology. You can go from zero to a billion documents without thinking too much about anything other than the amount of mass storage you have available.

    Every time I've used Lucene I have combined it with a SQL provider. It's not necessarily about one or the other. The FTS facilities within the various SQL providers are convenient, but not as capable by comparison. I don't think mixing these into the same thing makes sense. They are two very different animals that are better joined by way of the document ids.

    philippemnoel 3 days

    Under the hood, ParadeDB is built by integrating Tantivy (a Lucene-inspired Rust search library) inside Postgres. This is to say: I agree with you -- We're not trying to claim that Postgres itself is an alternative to Lucene, but rather that something like Lucene can be integrated inside Postgres so that you can get the power of both in a single system (or in a cluster of Postgres instances)

    monadicmonad 3 days

    why do I want them in a single system?

    inbx0 2 days

      - saves infra costs 
      - saves infra headaches 
      - devs only need to be experts in one system (or well I guess one and a half, probably there's something to learn about ParadeDB too, but probably less than in learning Lucine) 
      - no need to worry about keeping data up to date in the separate seach system
      - all data is available when you want to do new queries that you handn't thought of when implementing the data transfer/indexing

    ddorian43 3 days

    Its easier to have 1 system until a certain scale.