A table community as id: int, name: varchar. Another table category_people as community_id: int, person_id: int. A JOIN with LIMIT query could be
SELECT b.user_id, group_concat(a.name SEPARATOR ',') as groups FROM communities a JOIN communities_users b ON a.id = b.community_id GROUP BY b.user_id LIMIT 1000 OFFSET 2000;
In this query, will MySQL perform any internal optimizations and (a) do the limit,offset part first and join later or (b) perform a join on full table and then fetch the limit, offset window?
Referencing the MySQL 5.6 Manual on LIMIT Optimization, it appears to be (a):
“As soon as MySQL has sent the required number of rows to the client, it aborts the query unless you are using SQL_CALC_FOUND_ROWS.”