Live data from Hacker News

450× Faster Joins with Index Condition Pushdown

readyset.io

21–30 of 61 posts

Re: 450× Faster Joins with Index Condition Pushdown

#21

Earlier quoted context omitted.

Why downvote?

Reads like an ad written by an LLM, is my guess. It could just be that they translated from their original language to English and got that as a byproduct. Many such cases.

It also does not add anything interesting to the discussion. Like, why add a bland summary of the article?

Re: 450× Faster Joins with Index Condition Pushdown

#22

I read their website landing page but it’s still kinda confusing — what exactly is readyset? It all sounds like it’s a cache you can set up in front of MySQL/postgres. But then this article is talking about implementing joins which is what the database itself would do, not a cache. But then the blurbs talk about it like it’s a “CDN for your database” that brings your data to the edge. What the heck is it?!

ReadySet is basically "incremental view maintenance" but applied to arbitrary SQL queries. It acts like a caching proxy for your database, but it simultaneously ingests the replication log from the system in order to see things happen. Then it uses that information to perform "incremental" updates of data it has cached, so that if you requery something, it is much faster.

Naive example: let's say you had a query that was a table scan and it computed the average age of all users in the users table. If you insert a new row into the users table and then rerun the query, you'd expect another table scan, so it will grow over time. In a traditional setup, you might cache this query and only update it "every once in a while." Instead, ReadySet can decompose this query into an "incremental program", run it, cache the result -- and then when it sees the insert into the table it incrementally updates the underlying data cache. That means the second run would actually be fast, and the cost to update the cache is only proportional to the underlying change, not the size of the table.

ReadySet is derived from research on Noira, whose paper is here: https://www.usenix.org/conference/osdi18/presentation/gjengs...

Re: 450× Faster Joins with Index Condition Pushdown

#24

Maybe it's not obvious initially, but in retrospect, this handling of joins feels like the obvious way to handle it. Push down filters to read the least data possible. Or, know your data and be able to tell the query engine which kind of join strategy you would like (hash vs push down)

Decades ago we used to provide hints in queries based on "knowing the data" but modern optimizers have a lot better statistics on indexes, and the need to tell the query optimizer what to do should be rare.

Yes, but the problem is that optimizers will sometimes change join conditions without warning in production.

There is a real need to be able to take key queries and say, "don't change the way you run this query". Most databases offer this. Unfortunately PostgreSQL doesn't. There are ways to force the join (eg using a series of queries with explicit temporary tables), but all create overhead. And the result is that a PostgreSQL website will sometimes change a good query plan to a bad one, then have problems. Just because it is Tuesday.

Re: 450× Faster Joins with Index Condition Pushdown

#25

Another example of row based dbs somehow being insanely slow compared to column based. Just an endless sequence of misbehavior and we’re waving it off as rows work good for specific lookups but columns for aggregations, yet here it is all the other stuff that is unreasonably slow.

I feel like this is more an example of: “We filtered first instead of reading an entire table from disk and performing a lookup” Where both OLAP and OLTP dbms would benefit. To your point, it’s clear certain workloads lend themselves to OLAP and columnar storage much better, but “an endless sequence of misbehavior” seems a bit harsh .

It's not harsh.

Recent example, have 1GB of data in total across tables. Query needs 20 minutes. Obvious quadratic/cubic-or-even-worse behavior.

I disable nested loop join and it's 4 seconds. Still slow, but don't want to spend time figuring out why it's slower than reading 1GB of data and pipelining the computation so that it's just 1 second, or even faster given the beefy NVME where files are stored (ignoring that I actually have good indices and the surface area of the query is probably 10MB and not 1GB).

How can the strategy be slower than downloading 1GB of data and gluing it together in Python?

Something is just off with the level of abstraction, query planner relying on weird stats. The whole system, outside of its transactional guarantees, just sucks.

Another example where materializing CTE reduces exec time from 2 seconds to 50ms, because then you somehow hint to the query planner that result of that CTE is small.

So even PostgreSQL is filled with these endless riddles in misbehavior, even though PhDs boast about who knows what in the query optimizer and will make an effort to belittle my criticism by repeating the "1 row" vs "agg all rows" as if I'm in elementary school and don't know how to use both OLTP or OLAP systems.

Unlike column dbs where I know it's some nice fused group-by/map/reduce behavior where I avoid joins like plague and there's no query planner, stats maintenance, indices, or other mumbo-jumbo that does not do anything at all most of the time.

Most of my workloads are extremely tiny and I am familiar with how to structure schemas for OLTP and OLAP and I just dislike how most relational databases work.

Re: 450× Faster Joins with Index Condition Pushdown

#26

Earlier quoted context omitted.

Why downvote?

Reads like an ad written by an LLM, is my guess. It could just be that they translated from their original language to English and got that as a byproduct. Many such cases.

its literally the author of the article.

Re: 450× Faster Joins with Index Condition Pushdown

#27
post #23

Shouldn't the query planner catch things like this? Sounds like a performance bug if this happens in Postgres.

Yea this is pretty fucking basic stuff. Any competent optimization engine should be doing this. "push down indexes as much as possible" is literally the first thing a query planner should be trying to do

Re: 450× Faster Joins with Index Condition Pushdown

#28
post #24

Earlier quoted context omitted.

Decades ago we used to provide hints in queries based on "knowing the data" but modern optimizers have a lot better statistics on indexes, and the need to tell the query optimizer what to do should be rare.

Yes, but the problem is that optimizers will sometimes change join conditions without warning in production. There is a real need to be able to take key queries and say, "don't change the way you run this query". Most databases offer this. Unfortunately PostgreSQL doesn't. There are ways to force the join (eg using a series of queries with explicit temporary tables), but all create overhead. And the result is that a…

> There is a real need to be able to take key queries and say, "don't change the way you run this query".

We've hit this with MSSQL too. Suddenly production is down because for whatever reason MSSQL decided to forget its good plan and instead table scan, and then continue to reuse that cached table-scanning plan.

For one specific query MSSQL likes to do this with at a certain customer we've so far just added the minutes since start of year as a dummy column, while we work on more pressing issues. Very blunt, yet it works.

Re: 450× Faster Joins with Index Condition Pushdown

#30
post #21

Earlier quoted context omitted.

Reads like an ad written by an LLM, is my guess. It could just be that they translated from their original language to English and got that as a byproduct. Many such cases.

It also does not add anything interesting to the discussion. Like, why add a bland summary of the article?

So you don't have to read the article to figure out if you want to read the article?

I for one appreciate such comments, given the guidelines to avoid submission summaries.

Post reply on HN