Optimizing Top K in Postgres
Posted by philippemnoel 2 days ago
Comments
Comment by bob1029 19 hours ago
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.
Comment by philippemnoel 10 hours ago
Comment by monadicmonad 2 hours ago
Comment by jmgimeno 19 hours ago
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.
Comment by Cervisia 18 hours ago
Comment by igorw 17 hours ago
Comment by dragon96 19 hours ago
Comment by mattashii 17 hours ago
Comment by Tostino 13 hours ago
Comment by davidelettieri 20 hours ago
Comment by GrayShade 20 hours ago
Comment by philippemnoel 9 hours ago
Comment by h1fra 17 hours ago
Comment by esafak 11 hours ago
Comment by philippemnoel 10 hours ago
Comment by ajstars 12 hours ago
Comment by Vadim_samokhin 18 hours ago
Comment by JEONSEWON 21 hours ago
Comment by bbshfishe 20 hours ago
Comment by tacone 19 hours ago
Comment by hrmtst93837 16 hours ago
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.