performance - single join select vs. multiple simple selects

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

What is better as far as performance goes?

8条回答
  •  孤街浪徒
    2020-12-15 05:04

    There is only one way to know: Time it.

    In general, I think a single join enables the database to do a lot of optimizations, as it can see all the tables it needs to scan, overhead is reduced, and it can build up the result set locally.

    Recently, I had about 100 select-statements which I changed into a JOIN in my code. With a few indexes, I was able to go from 1 minute running time to about 0.6 seconds.

提交回复
热议问题