i would like to know if limit and offset are executed after the row were selected:
SELECT * FROM users WHERE id > 4 LIMIT 0,90 ORDER BY datetime DESC;
Does this query first selects all the users’s rows then apply the LIMIT, or does this query first apply the LIMIT then selects the users’s rows?
The
FROMclause is the first to be executed in the query, then theWHEREclause. After that theLIMITclause is applied.So, the following are the Logical query processing steps for the query you posted:
FROMclause return all users.WHEREclause is applied. Only the users withid > 4get passed to the next step.LIMIT.