Thursday, 15 July 2010

Is LIMIT x, y absolutely equivalent to OFFSET x LIMIT y in MySQL? -



Is LIMIT x, y absolutely equivalent to OFFSET x LIMIT y in MySQL? -

i'm posting question resource others couldn't find explicitly answering online: limit x,y syntax performatively equivalent offset x, limit y?

according official mysql docs:

for compatibility postgresql, mysql supports limit row_count offset offset syntax.

this implies me absolutely equivalent.

but can't find official doc saying explicitly. i'm 99% sure there aren't low level differences, love official stamp of approval , peace of mind. thanks.

i wasn't sure, , can't find documentation either, tested , seems work fine. results:

andrew@uf ~ $ mysql --version mysql ver 14.14 distrib 5.1.66, debian-linux-gnu (x86_64) using readline 5.1 ... mysql (sandbox) > select * db1.t1 limit 1, 2; +-------+------------+-----------------------------+ | grpid | grpcode | grpdesc | +-------+------------+-----------------------------+ | 2 | intl_leads | international leads | | 3 | cpe_leads | cpe-specific domestic leads | +-------+------------+-----------------------------+ mysql (sandbox) > select * db1.t1 limit 2 offset 1; +-------+------------+-----------------------------+ | grpid | grpcode | grpdesc | +-------+------------+-----------------------------+ | 2 | intl_leads | international leads | | 3 | cpe_leads | cpe-specific domestic leads | +-------+------------+-----------------------------+

so yeah. did more testing this, don't want post of it. that's pretty handy know syntax makes more sense me.

mysql

No comments:

Post a Comment