performance - single join select vs. multiple simple selects

后端 未结 8 1566
逝去的感伤
逝去的感伤 2020-12-15 04:08

What is better as far as performance goes?

相关标签:
8条回答
  • 2020-12-15 05:09

    A single join will usually outperform multiple single selects. However, there are too many different cases that fit your question. It isn't wise to lump them together under a single simple rule.

    More important, a single join will usually be easier for the next programmer to understand and to revise, provided that you and the next programmer "speak the same language" when you use SQL. I'm talking about the language of sets of tuples.

    And equally important is that database physical design and query design need to focus first on the questions that will result in a ten for one speed improvement, not on a 10% speed imporvement. If you were doing thousands of simple selects versus a single join, you might get a ten for one advantage. If you are doing three or four simple selects, you won't see a big improvement one way or the other.

    0 讨论(0)
  • 2020-12-15 05:10

    If your database has lots of data .... and there are multiple joins then please use indexing for better performance.

    If there are left/right outer joins in this case , then use multiple selects.

    It all depends on your db size, your query, the indexes (which include primary and foreign keys also) ... One cannot reach on conclusion with yes/no on your question.

    0 讨论(0)
提交回复
热议问题