LIMIT keeps the first rows after sorting.

highlighted = computed this step

Keep a short prefix

LIMIT keeps the first rows after ordering.

order first, then limit\text{order first, then limit}

Apply the limit

The page keeps 3 rows and skips 2 later rows.

page rows=3\text{page rows}=3

Ordering examples are tiny finite table transforms; SQL dialects, NULL ordering, collations, indexes, optimizer behavior, performance, and product behavior are out of scope.

Keep a short prefix: base tablesourceRowidkindscore01book9012game7523book7534game9045book90 order bycolumndirectionscoredescidasc sort keyssourceRowkey0[90, 1]1[75, 2]2[75, 3]3[90, 4]4[90, 5] ordered rowssourceRowidkindscore01book9034game9045book9012game7523book75 page rowssourceRowidkindscore01book9034game9045book90 tie groupskeysourceRowsnonenone order factsfactvaluerowCount5orderColumnCount2orderedRowCount5offset0limit3pageRowCount3skippedBeforeCount0skippedAfterCount2unstableTiesnodeterministicTieOrdernot_needed

Look after the page

Skipped-after rows are still in the ordered rows table, just outside the page.

prefix only\text{prefix only}

Summary

LIMIT does not change the sort; it cuts a window from the sorted rows.

sorted prefix\text{sorted prefix}