Should I use one big SQL Select statement or several small ones?

后端 未结 7 625
一整个雨季
一整个雨季 2021-01-17 08:54

I\'m building a PHP page with data sent from MySQL.

Is it better to have

  • 1 SELECT query with 4 table joins, or
  • 4 small SELE
7条回答
  •  悲&欢浪女
    2021-01-17 09:17

    Generally, it's better to have one SELECT statement. One of the main reasons to have databases is that they are fast at processing information, particularly if it is in the format of query.

    If there is any drawback to this approach, it's that there are some kinds of analysis that you can't do with one big SELECT statement. RDBMS purists will insist that this is a database design problem, in which case you are back to my original suggestion.

提交回复
热议问题