3 ms·
It's actually worst than that because cartesian product is the default mode of SQL. JOIN clauses are already a kind of mitigation that force you to be more expl
by Twisell 7y ago
It's actually worst than that because cartesian product is the default mode of SQL. JOIN clauses are already a kind of mitigation that force you to be more explicit.
With modern SQL even if you only mention no table at all in the FROM clause you can get "duplicate" if you use set returning function (see: https://www.postgresql.org/docs/current/functions-srf.html https://www.postgresql.org/docs/current/functions-srf.html).
This is both why you should be careful and why this is a really powerful tool to manipulate datasets. But usually "everything is a cartesian product" is one of the first (and yes very important) thing you learn of SQL.
- barrkel 7y agoYes, I know, everybody knows. My point is that SQL doesn't help you catch those errors where your join clause doesn't match rows uniquely. You can know that the product is the default and still forget that extra bit in the predicate.