For finding comments by user id via the automatic paged query selectAllForAdmin, a query counting the total number of rows selectAllForAdmin retrieves will be issued:
SELECT
COUNT(1)
FROM
comment c
LEFT JOIN topic t ON c.topic_id = t.id
LEFT JOIN user u ON u.id = c.user_id
WHERE
c.in_time BETWEEN '2019-10-01'
AND '2019-10-31'
However, since the query use comment to left jointopic and user table on primary keyid, the final result is the same to query select count(1) from comment where in_time BETWEEN '2019-10-01' AND '2019-10-31' without any join operator. So the counting query has a chance to be optimized.
For finding comments by user id via the automatic paged query selectAllForAdmin, a query counting the total number of rows
selectAllForAdmin
retrieves will be issued:However, since the query use
comment
to left jointopic
anduser
table on primary keyid
, the final result is the same to queryselect count(1) from comment where in_time BETWEEN '2019-10-01' AND '2019-10-31'
without any join operator. So the counting query has a chance to be optimized.