473,394 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

DB2 UDB LUW: query, cursor types and optimization

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

Nov 12 '05 #1
4 3754
Bernard Dhooghe wrote:
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

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
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2
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

Nov 12 '05 #3
Bernard Dhooghe wrote:
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?

The cursor is compiled at OPEN. Presumably all these attributes are set
by the time you do OPEN.

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #4
Thank you Serge, clarifies difference between prep and access plan
build step (for dynamic programming interface).

Bernard Dhooghe

Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Bernard Dhooghe | last post by:
Environment: DB2 UDB LUW (8.1.1.64) DB2 Universal Database Version 8.1, 5622-044 (c) Copyright IBM Corp. 1991, 2002 Licensed Material - Program Property of IBM IBM DB2 Universal Database SQL...
12
by: WantedToBeDBA | last post by:
Hi all, db2 => create table emp(empno int not null primary key, \ db2 (cont.) => sex char(1) not null constraint s_check check \ db2 (cont.) => (sex in ('m','f')) \ db2 (cont.) => not enforced...
11
by: 73blazer | last post by:
We are migrating a customer from Version 7.1 FP3, to Version 8.2 (8.1 FP8). For the most part, things are faster, but there is one query that is much much slower, and it is a query that is used all...
20
by: GS | last post by:
The stdint.h header definition mentions five integer categories, 1) exact width, eg., int32_t 2) at least as wide as, eg., int_least32_t 3) as fast as possible but at least as wide as, eg.,...
7
by: serge | last post by:
How can I run a single SP by asking multiple sales question either by using the logical operator AND for all the questions; or using the logical operator OR for all the questions. So it's always...
10
by: Raj | last post by:
I have an MDC index on Big_A.Dt column. The following query always goes for a table scan. SELECT Key, Cd, Dt, SUM(Big_A ) FROM ( SELECT Big_A.Key , small_3.Cd,
5
by: wugon.net | last post by:
question: db2 LUW V8 UNION ALL with table function month() have bad query performance Env: db2 LUW V8 + FP14 Problem : We have history data from 2005/01/01 ~ 2007/05/xx in single big...
1
by: Vinod Sadanandan | last post by:
A Roadmap To Query Tuning ============================ For each SQL statement, there are different approaches that could be used to retrieve the required data. Optimization is the process of...
2
by: F | last post by:
Is DB2 on z/OS same as DB2 on LUW ? Will my DB2 DBA on one environment have to retrain again on the other ? Thanks
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.