Hi
Am Mittwoch 01 September 2010 23:04 schrieb Ashish Kulkarni:

FETCH FIRST 50 ROWS ONLY
OPTIMIZE FOR 2 ROWS

with both of this you tell the optimizer that the query has a high
selectivity. If the table has only some 10000 records, there would be no
effect, if the table has 100 of millions of records, the optimizer tends in
the direction to use an index (if available) over a full table scan. This
clause might be effective, when a full table scan causes slow perfomance and
is not needed.
the diffrence between the two is, that the first limits the ResultSet to 50
rows, the second does not set a limit. You should have in mind, that defining
a resultSet opens an accesspath, but normally it does not fetch any row.
conclusion of this: optimize for 50 rows and fetch first 50 rows only and
afterwards 10 fetch operations (in Java next()) would be comparable fast or
slow.

FOR READ ONLY

it depends: if you have a lock level allowing dirty reads (no commit, auto
commit or read uncommited, most databases would read blocks of data and cache
it and this mostly would speed up your query. Normally it would not slow down
the query, even if you would fetch only 1 row, because the Operating system
transfers data in blocks anyway.

WITH NC;

thats no performance relevant option for most database systems (including
DB2/400). reading data, there is no diffrence between no commit and read
uncommitted and writing data is optimized for commitment controll. You should
have in mind two things:
writing data using sql without commitment controll is not state of the art and
you have the risc, that data changes between read and write, depending on
your database design and your code.
using commitment controll, you must ensure, that your transactions are defined
correctly, collecting lots of record locks might slow down your performance.

D*B


--
Ashish
www.ayurwellness.com
www.mysoftwareneeds.com


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.