For finding topics with user information via the automatic paged query selectAll, a query counting the total number of rows selectAll retrieves will be issued:
SELECT
COUNT(1)
FROM
(
select
t.*,
u.username,
u.avatar
from
topic t
left join user u on t.user_id = u.id
order by
t.top desc,
t.in_time desc
) TOTAL
However, since the query use topic to left joinuser table on primary keyu.id, the final result is the same to query select count(1) from topic without any join operator or order by. So the counting query has a chance to be optimized.
For finding topics with user information via the automatic paged query selectAll, a query counting the total number of rows
selectAll
retrieves will be issued:However, since the query use
topic
to left joinuser
table on primary keyu.id
, the final result is the same to queryselect count(1) from topic
without any join operator or order by. So the counting query has a chance to be optimized.