You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SELECT c_custkey
FROM customer
WHERE c_acctbal < (
SELECTMAX(o_totalprice)
FROM orders
WHERE o_custkey = c_custkey
)
returns all customers who have at least one order but cannot afford any of them.
We currently optimize it to an inner join that has c_acctbal < o_totalprice as its predicate.
However, the query could also be written in an even more efficient way that uses an equi join:
SELECT c_custkey
FROM customer
JOIN orders ON o_custkey = c_custkey
GROUP BY c_custkey, c_acctbal
HAVING c_acctbal <MAX(o_totalprice)
Specifically for this case, it is possible to boost it even further:
SELECT DISTINCT c_custkey
FROM customer
JOIN orders ON o_custkey = c_custkey
WHERE c_acctbal < o_totalprice
The SubqueryToJoinRule should apply these reformulation techniques when possible.
The text was updated successfully, but these errors were encountered:
returns all customers who have at least one order but cannot afford any of them.
We currently optimize it to an inner join that has
c_acctbal < o_totalprice
as its predicate.However, the query could also be written in an even more efficient way that uses an equi join:
Specifically for this case, it is possible to boost it even further:
The
SubqueryToJoinRule
should apply these reformulation techniques when possible.The text was updated successfully, but these errors were encountered: