Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / August 2005

Tip: Looking for answers? Try searching our database.

DB2 UDB LUW: query, cursor types and optimization

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bernard Dhooghe - 29 Aug 2005 17:00 GMT
To retrieve data from a query where multiple rows can be returned, a
cursor can be used.

Different programming interface exist for cursors: embedded SQL, CLI,
SQL PL, SQLJ, JDBC.

I we look at the CLI interface, as a statement is first prepared in CLI
before a cursor is associated with it, the cursor attributes are not
known at prepare time. Does it mean that the query path for retrieving
rows is not dependent of the cursor attributes in DB2 UDB LUW? Is there
a second "optimization" step to choose the way the rows returned by the
query will be used by the cursor? Example: the query "select
primary_key from table order by primary_key" can retrieve date directly
from the index part and this could be passed as is directly to the
cursor.

Bernard Dhooghe
Serge Rielau - 29 Aug 2005 17:51 GMT
> To retrieve data from a query where multiple rows can be returned, a
> cursor can be used.
[quoted text clipped - 13 lines]
>
> Bernard Dhooghe

I'm not clear I follow you on that one.
The ORDER BY clause is part of the query.
There is only one compilation/optimization of the cursor.
Can you give a more complete example?

Cheers
Serge
Signature

Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab

Bernard Dhooghe - 29 Aug 2005 19:09 GMT
Let us take as example:

select * from mytable order by primary_key fetch first 1000 rows only
optimize for 1 row

When will the access plan be choosen for this query?

Will it be at prepare time (taken the example of the CLI interface)
(one compilation/optimization step, being it SQLJ, JDBC, CLI, ...), or
at first fetch time, when all attributes associated with the cursor
(read-only or not, scroll or not, keyset or not) are known, wich could
influence the path decision and how the data will be materialized for
the application?  

Bernard Dhooghe
Serge Rielau - 30 Aug 2005 03:07 GMT
> Let us take as example:
>
[quoted text clipped - 9 lines]
> influence the path decision and how the data will be materialized for
> the application?  
The cursor is compiled at OPEN. Presumably all these attributes are set
by the time you do OPEN.

Cheers
Serge

Signature

Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab

Bernard Dhooghe - 30 Aug 2005 08:33 GMT
Thank you Serge, clarifies difference between prep and access plan
build step (for dynamic programming interface).

Bernard Dhooghe
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.