Pierre,

> 
> Regarding limit 1 offset 2, I am not sure I fully understand what you
> mean.
> 
> 
> For me:
> 
> 
> limit 1 => first row
> limit 1 offset 0 => first row
> limit 1 offset 1 => first row
> limit 1 offset 2 => second row

offset N means 'skip N first rows'. So correct list of cases is as
follows:

limit 1 => first row
limit 1 offset 0 => first row
limit 1 offset 1 => skip one row and return second row
limit 1 offset 2 => skip two rows and... ops, nothing to return

Note that Virtuoso frequently fails to compile "offset N" without "limit
M" in front of it. This is because "limit...offset..." is used with some
"order by" and SQL processor should usually allocate intermediate table
of M+N best candidates for final result to not sort everything instead
of preemptive election of most appropriate results. "offset" without
"limit" results in unrealistic SQL code. (What if application will
retrieve first billion of triples after skipping first ten? Having no
"limit", compiler tries to be ready to the worst case).

Best Regards,
Ivan Mikhailov
OpenLink Software



Reply via email to