The example is this table, she takes two result sets here, one to get the total number of rows, generate the following Operation panel,
The other generates the above data.
I'm just wondering, just using a total result set is OK, the index array of the result set can also generate the above word,
Why not use two result sets?
Is this good for performance, or is it another reason?
Reply content:
The example is this table, she takes two result sets here, one to get the total number of rows, generate the following Operation panel,
The other generates the above data.
I'm just wondering, just using a total result set is OK, the index array of the result set can also generate the above word,
Why not use two result sets?
Is this good for performance, or is it another reason?
It is not very good to bring the question directly, for the following reasons:
Now that you have asked for doubt, the suspicion is that you have your own answer, but you are not sure that you are right.
In this case, I am very much looking forward to your question and also write your own solution in it, there are two advantages:
1-Your answer is not right, others can be pointed to point out the problem
2-Your answer is yes, we praise you, you gain confidence.
In fact, a lot of information contains a variety of errors, it is true that the second statement should be SELECT COUNT (*).
Now that you've tagged MySQL, the positive solution to this SQL should be
select SQL_CALC_FOUND_ROWS * from table limit x, y
Then by select found_rows() getting the total number of records that match the criteria.
When you have thousands of data, I think it's easy to understand the difference between the 10 rows and the total fetch performance.
Do not return the total number of records, how do you calculate the number of pages
Each page of data returns only n data via limit x, Y,
Paging is to avoid getting too much data at once.