473,466 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

interpertting a db2expln

Hi,

I'm trying to interpet a db2 explain. I'm trying to determine if the SQL is
being executed as I expect/hope.

The sql is generally:

select key from table where key1=value and key2 > value2 and key2 < maxkey
order by key2 fetch first 1 row only

2 notes: key1 = value is 99% of the table and the max key is more or less
useless b/c its always the last possible key, making the statement for
practical purposes:

select key from table key2 > value2 order by key2 fetch first 1 row only

By big question is: If their were 26 rows w/ keys A-Z , and the value of
value2 is B, does the explain show that the sql statement still inserts C-Z
into the temp table and sort it?

Below is the explain of the statement in question.

Thanks!
Frank

--

-------------------- SECTION ---------------------------------------
Section = 17
SQL Statement:

SELECT LFKEY, CDATA INTO :H00038 :H00039 , :H00018 :H00019
FROM RCFGTD
WHERE LFPFX=:H00004 :H00005 AND LFKEY >= :H00038 :H00039 AND LFKEY
<= :H00020 :H00021
ORDER BY lfkey
FETCH FIRST 1 ROW ONLY
Section Code Page = 819

Estimated Cost = 78.628693
Estimated Cardinality = 1.000000

Table Constructor
| 1-Row(s)
Residual Predicate(s)
| #Predicates = 1
Nested Loop Join
| Piped Inner
| Access Table Name = PRODPCIA.RCFGTD ID = 22,115
| | #Columns = 0
| | Index Scan: Name = PRODPCIA.LNG01_RCFGTD_PK ID = 1
| | | Regular Index (Clustered)
| | | Index Columns:
| | | | 1: LFPFX (Ascending)
| | | | 2: LFKEY (Ascending)
| | | #Key Columns = 2
| | | | Start Key: Inclusive Value
| | | | | 1: ?
| | | | | 2: ?
| | | | Stop Key: Inclusive Value
| | | | | 1: ?
| | | | | 2: ?
| | | Index-Only Access
| | | Index Prefetch: None
| | | Insert Into Sorted Temp Table ID = t1
| | | | #Columns = 1
| | | | #Sort Key Columns = 1
| | | | | Key 1: (Ascending)
| | | | Sortheap Allocation Parameters:
| | | | | #Rows = 43
| | | | | Row Width = 12
| | | | Piped
| | | | Duplicate Elimination
| | Isolation Level: Uncommitted Read
| | Lock Intents
| | | Table: Intent None
| | | Row : None
| Sorted Temp Table Completion ID = t1
| List Prefetch Preparation
| | Access Table Name = PRODPCIA.RCFGTD ID = 22,115
| | | #Columns = 2
| | | Relation Scan
| | | | Prefetch: 5 Pages
| | | Lock Intents
| | | | Table: Intent Share
| | | | Row : Next Key Share
| | | Sargable Predicate(s)
| | | | #Predicates = 3
Insert Into Sorted Temp Table ID = t2
| #Columns = 2
| #Sort Key Columns = 1
| | Key 1: LFKEY (Ascending)
| Sortheap Allocation Parameters:
| | #Rows = 1
| | Row Width = 3504
| | Sort Limited To Estimated Row Count
| Piped
Access Temp Table ID = t2
| #Columns = 2
| Single Record
| Relation Scan
| | Prefetch: Eligible
Return Data to Application
| #Columns = 2

End of section
Optimizer Plan:

RETURN
( 1)
|
TBSCAN
( 2)
|
SORT
( 3)
|
NLJOIN
( 4)
/ \
TBSCAN RIDSCN
( 5) ( 7)
| |
TFunc: SORT
SYSIBM ( 8)
GENROW |
IXSCAN
( 9)
/ \
Index: Table:
PRODPCIA PRODPCIA
LNG01_RCFGTD_PK RCFGTD


Nov 12 '05 #1
2 6619
Feed the query into
db2 EXPLAIN PLAN FOR <stmt>
then do:
db2exfmt

The result will be a lot more verbose.
db2expln reverse engineers (disassembles) the plan from the runtime.

E.g. db2exfmt will tell you the estimated (or proven) cardinality of
each plan operator.
In your case I would expect a "truncated sort".
Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2
Hey Serge,

Is there actually somewhere a good document describing the explain plan and
what each section means etc..?
For example, MAXPAGES. From what I understand so far is the optimizer
setting the maximum number of pages to prefetch correct?
But I've seen a setting of like 1000, so that would mean to maximum fetch
1000 pages correct?
Thus if I have a prefetchsize of 32, I would get 32 prefetch requests
correct?

So if it would for example say 16, would this mean that although my
prefetchsize if set to 32, the optimizer will override this and only get 16
pages?

I can not find any good documentation explaining every item within the
explain output, and what it means etc..

Thanks.

"Serge Rielau" <sr*****@ca.eye-be-em.com> wrote in message
news:c1**********@hanover.torolab.ibm.com...
Feed the query into
db2 EXPLAIN PLAN FOR <stmt>
then do:
db2exfmt

The result will be a lot more verbose.
db2expln reverse engineers (disassembles) the plan from the runtime.

E.g. db2exfmt will tell you the estimated (or proven) cardinality of
each plan operator.
In your case I would expect a "truncated sort".
Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab

Nov 12 '05 #3

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

Similar topics

2
by: LazyAnt | last post by:
Hello, I have DB2 v8.1 for Linux for a class environment; each user has his/her own database as dbadm and they are suppose to study queries from another database. They have the right...
3
by: Terry | last post by:
Hi All, Im trying to run db2expln over some sql in order to find out why its so slow. I receive the following error message. LINE MESSAGES FOR DYNEXPLN.sqc ------ ...
14
by: Ina Schmitz | last post by:
Hello all, I don't succeed in displaying the explain plan. I use IBM DB2 Universal Database 8.2. I tried to do the example given in the online help for "Visual Explain". The tables...
2
by: Ion | last post by:
Hi, I have a sql procedure that (among others) deletes a row in a table (very small). The table has a foreign key - ON DELETE NO ACTION that points to a large table (child). There is an index...
4
by: tuarek | last post by:
Hi all, Can you suggest any reference on analyzing db2expln results? Regards, Mehmet
12
by: Joachim Pense | last post by:
Is there recommended way to get the execution plan for queries involving global temporary tables (from the UNIX command line or within a script)? I run the queries in Perl scripts, and the only...
1
by: jefftyzzer | last post by:
Colleagues: Can anyone tell me what the number to the right of "Index Prefetch: Eligible" designates in the output from db2expln, e.g., "Index Prefetch: Eligible 14409"? I see such a number...
1
by: Troels Arvin | last post by:
Hello, In a DB2 LUW v. 8.1.1.96, I have a hard time giving users access to the db2expln utility. Let's say that user FOOBAR needs to be able to run the db2expln utility. I do: - provide...
5
by: srilata83 | last post by:
Hi, I am trying to query a big table which contains huge data,I just tried to check the no of records of table, i have run the query for COUNT(*) in QMF, But i am not getting the result , i am...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.