1. Write a complex SQL, multi-table query associated, in the service layer code only need to use the SQL,
More than 2. Write a simple SQL, are generally single table query, write cycle, in the service layer code by using many times to get the data,
So, we should priority is in what way? What are their usage scenarios?
CodePudding user response:
Use the first way,The second, basically there is no market,
CodePudding user response:
The amount of data, if the data is less, with the first way, data, with the second,CodePudding user response:
If the application side don't do any processing, just simple loop, and then constantly invoke more simple SQL; Each network combined with SQL running back and forth time, data volume growth will lead to a sharp drop in performance,Complex multi-table connection need to pay attention to the performance issue SQL statements, all kinds of indexes was set up,
Usually the first way will be more reliable, because you use a relational database, rather than no,
CodePudding user response:
Proposal 2Is advantageous for the screening and subsequent problems, a complex SQL, is not recommended for general developer
If it is a development, follow-up without any changes, a proposal
CodePudding user response:
A proposal, more reliable, scheme 2 in code to do more operation call it is not recommendedCodePudding user response:
From the consideration on the performance, there is no doubt that option 1,If the SQL is very complex, can consider to take apart into 2 ~ 3 SQL
The second solution is not recommended, unless the data volume is small, there is no performance problem
CodePudding user response:
Link performance is a big problem, you can refer to the "big master table performance optimization method of correlation" and "how to optimize performance of the JOIN these two articles