Cartesian product appears in SQL statements

Source: Internet
Author: User

No join condition results in Cartesian product

People who have studied linear algebra know that the Cartesian product is popularly said that each member of the two set is associated with a random member of the other party's collection. It can be imagined that, in SQL queries, the Cartesian product is produced when there is no join condition for two table join queries. This is the most common case of performance problems caused by our Cartesian product: The developer misses the join condition when writing the code.

SQL in which the Cartesian product occurs:


This statement is actually only a part of the SQL statement, the problem is that there is a part of the table OrderForm, so from the OrderForm, but the above part of the statement is not practical to OrderForm, but not set the conditions led to the Cartesian product.

Workaround: Use the left JOIN



Cartesian product appears in SQL statements

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.