News for hackers. Stuff that matters.
Re:Speeding up SQL queries by orders of magnitude using UNION by gfody on Saturday March 20, 2021 @10:45PM (#26527730)
I think the point is rather that a join with a condition (which is the norm) is almost never actually executed as a cartesian product. take for example from tfa

  select * from customer_order_items
the grain is one row per customer order item, and the next two joins don't change that

  select * from customer_order_items join customer_orders on order_id
the grain is still one row per customer order item

  select * from customer_order_items join customer_orders on order_id join customers on customer_id
the grain is still one row per customer order item

..etc..

of course later on they screw it up and take the cartesian product of customer_order_items by employ_markouts, but it's just 2 big factors not 7 - their query did finish after a few seconds. usually mistakes involving cartesian products with 7 factors just run for hours and eventually throw out of memory.

There are no comments on this comment yet.