Subject | FIRST/SKIP and Sroed Procedures |
---|---|
Author | Alan McDonald |
Post date | 2004-01-24T11:46:17Z |
Now it is not hard to imagine that the engine can take a statement like
SELECT FIRST X SKIP Y * FROM TABLENAME ORDER BY FIELDNAME
and utilise an index on FIELDNAME to very quickly return just the gap of
records requested.
But I have just realised that you can also use
SELECT FIRST X SKIP Y * FROM SP_NAME(PARAM)
Now can someone tell me if the engine does indeed work out from the SP how
to do such an efficient read as in the first example, even when the body of
the SP can be quite complicated? Or does the engine return all records to
the SP, and then the gap of records to the client?
From looking at the Performance Analysis, it would suggest that the engine
does indeed short circuit the SP and read only the FIRST X records. This is
not just an anomaly is it?
thanks
Alan
SELECT FIRST X SKIP Y * FROM TABLENAME ORDER BY FIELDNAME
and utilise an index on FIELDNAME to very quickly return just the gap of
records requested.
But I have just realised that you can also use
SELECT FIRST X SKIP Y * FROM SP_NAME(PARAM)
Now can someone tell me if the engine does indeed work out from the SP how
to do such an efficient read as in the first example, even when the body of
the SP can be quite complicated? Or does the engine return all records to
the SP, and then the gap of records to the client?
From looking at the Performance Analysis, it would suggest that the engine
does indeed short circuit the SP and read only the FIRST X records. This is
not just an anomaly is it?
thanks
Alan