Is too many Left Joins a code smell?

前端 未结 8 1776
南笙
南笙 2021-01-01 09:30

If you have for example > 5 left joins in a query is that a code smell that there is ...

  • something wrong with your design?
  • you\'re doing too much in o
8条回答
  •  悲&欢浪女
    2021-01-01 09:41

    No, not at all. It's perfectly legitimate to construct a database design that uses a significant number of left joins on some queries.

    Having said that I would generally prefer to construct the database so that the number of cases where outer joins are required is limited as experience tends to suggest that (complex) queries that use them are more error prone and likely to give rise to maintenance problems.

    As an interesting historical aside, the early versions of IBM's DB2, when it ran on mainframes only, did not support outer joins (Oracle and Ingress both did at the time which was a major selling point). This lead to some interesting issues in database design as it was necessary to ensure that all expected data access requirements for the database could be solved using just inner joins.

提交回复
热议问题