For finding comments by user id via the automatic paged query selectByUserId, a query counting the total number of rows selectByUserId retrieves will be issued:
SELECT
COUNT(1)
FROM
comment c
LEFT JOIN topic t ON t.id = c.topic_id
LEFT JOIN user u ON t.user_id = u.id
LEFT JOIN user uu ON c.user_id = uu.id
WHERE
c.user_id = 3
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 user_id = 3 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 selectByUserId, a query counting the total number of rows
selectByUserId
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 user_id = 3
without any join operator. So the counting query has a chance to be optimized.