473,434 Members | 1,820 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,434 software developers and data experts.

who can explain this?

ENVIRONMENT:

DB2 OS/390 V6 Peoplesoft v8
I have a strange situation:

I have a table called TABLEA and it has indexes
Ind1
Ind2
Ind3

Now when I do this on the table

Select * from table where NAME='XYZ'

It is using an index IND1 and it is very slow.

But if I do this

Select * from table where substr(name,1,8)='XYZ' now it using
IND2 and it is very fast.

Now my question is why is this behaviour? And what caused substr to
use another index and efficiently.

Thanks
Nov 12 '05 #1
5 3300
"radhika" <ra************@hotmail.com> wrote in message
news:91**************************@posting.google.c om...
ENVIRONMENT:

DB2 OS/390 V6 Peoplesoft v8
I have a strange situation:

I have a table called TABLEA and it has indexes
Ind1
Ind2
Ind3

Now when I do this on the table

Select * from table where NAME='XYZ'

It is using an index IND1 and it is very slow.

But if I do this

Select * from table where substr(name,1,8)='XYZ' now it using
IND2 and it is very fast.

Now my question is why is this behaviour? And what caused substr to
use another index and efficiently.

Thanks


Please show the DDL of the indexes.

But often times, unexpected behavior of indexes is caused by disorganization
of the table and indexes. To resolve this, you should reorg the table and
indexes, then run runstats utility with full statistics captured, and then
rebind the plan (if static).
Nov 12 '05 #2
Can you post the CREATE statements for the tables and indexes? You might
be able to do this with db2look from a client workstation on Unix,
Windows or Linux?

radhika wrote:
ENVIRONMENT:

DB2 OS/390 V6 Peoplesoft v8
I have a strange situation:

I have a table called TABLEA and it has indexes
Ind1
Ind2
Ind3

Now when I do this on the table

Select * from table where NAME='XYZ'

It is using an index IND1 and it is very slow.

But if I do this

Select * from table where substr(name,1,8)='XYZ' now it using
IND2 and it is very fast.

Now my question is why is this behaviour? And what caused substr to
use another index and efficiently.

Thanks


Nov 12 '05 #3
O.K Here is the statements.

These are the CREATE INDEX statements.

Create unique index ind1 on table
(col1 , col2, col3, col4, col5)

create index ind2 on table (col1, col2, col3, col5, col6)

create index ind3(col1, col3)

create index ind4(col4)

Now without the substr it is using ind3 and it is very bad.
With the substr it is using ind4 and it is very good.

why is that?

This is on os/390 db2 v6

Thanks


Blair Adamache <ba*******@2muchspam.yahoo.com> wrote in message news:<bm**********@hanover.torolab.ibm.com>...
Can you post the CREATE statements for the tables and indexes? You might
be able to do this with db2look from a client workstation on Unix,
Windows or Linux?

radhika wrote:
ENVIRONMENT:

DB2 OS/390 V6 Peoplesoft v8
I have a strange situation:

I have a table called TABLEA and it has indexes
Ind1
Ind2
Ind3

Now when I do this on the table

Select * from table where NAME='XYZ'

It is using an index IND1 and it is very slow.

But if I do this

Select * from table where substr(name,1,8)='XYZ' now it using
IND2 and it is very fast.

Now my question is why is this behaviour? And what caused substr to
use another index and efficiently.

Thanks

Nov 12 '05 #4
> > radhika wrote:
ENVIRONMENT:

DB2 OS/390 V6 Peoplesoft v8
I have a strange situation:

I have a table called TABLEA and it has indexes
Ind1
Ind2
Ind3

Now when I do this on the table

Select * from table where NAME='XYZ'

It is using an index IND1 and it is very slow.

But if I do this

Select * from table where substr(name,1,8)='XYZ' now it using
IND2 and it is very fast.

Now my question is why is this behaviour? And what caused substr to
use another index and efficiently.

Thanks
"radhika" <ra************@hotmail.com> wrote in message
news:91**************************@posting.google.c om... O.K Here is the statements.

These are the CREATE INDEX statements.

Create unique index ind1 on table
(col1 , col2, col3, col4, col5)

create index ind2 on table (col1, col2, col3, col5, col6)

create index ind3(col1, col3)

create index ind4(col4)

Now without the substr it is using ind3 and it is very bad.
With the substr it is using ind4 and it is very good.

why is that?

This is on os/390 db2 v6

Thanks

1. Which column is NAME (col1, col2, col3, col4, col 5, or col6). I think
you made a mistake because ind3 and ind4 have completely different columns
in their indexes as described above.
2. I need the exact SQL statement and working storage definitions of any
host variables in that SQL statement. Host variables start with a colon.
3. You can also use NAME LIKE 'XYZ%' which may be better performing than
substr. In any case it is no worse and more widely accepted method.
4. It would be better if you disclosed which indexes are unique and which is
the clustered index. If no index is explicitly defined as clustered, then
the first index created is the clustered index. BTW, the employee table
should probably be clustered on last name or department (i.e., in a
multi-column index these columns need to be the first column in the
clustered index)..
Nov 12 '05 #5
maybe there is a variable on mvs/os390/zos that is similar to the luw db2
udb DB2_LIKE_VARCHAR?

PM
Nov 12 '05 #6

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

Similar topics

0
by: Bruce D | last post by:
I'm trying to understand MySQL better. I can't seem to figure out why the second query takes 2 minutes and the first query takes 12 seconds. It should be noted that the table, KBM, has 250...
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...
10
by: Jeff Boes | last post by:
I'm hoping there's someone here with experience in building the Visual Explain tool from Red Hat. I downloaded it and the J2 SDK, but when I attempt to follow the build instructions, I get messages...
5
by: Jon Lapham | last post by:
I have been using the EXPLAIN ANALYZE command to debug some performance bottlenecks in my database. In doing so, I have found an oddity (to me anyway). The "19ms" total runtime reported below...
2
by: Dan Sugalski | last post by:
Is there any way to convince explain to go do its thing when given a query with placeholders in it? I'm trying to do some performance checking of some of the queries built into a system I'm...
4
by: marklawford | last post by:
Not having earned my DBA badge from the scouts just yet I'm a little lost with an error I'm getting. We've just upgraded our development database from 7.2 to 8.2 as the first step in upgrading...
2
by: heming_g | last post by:
two tables with the same table structure : tb_xxx and tb_xxx_tmp in table tb_xxx , column "listno" is the primary key of itself and foreign key of dozen of tables . here is my sql .. "...
0
by: dataguy | last post by:
I have my developers explaining the stored procedures that they write using visual studio. These stored procedures are for DB2 os390. In one case, one of the developers has defined a global...
5
by: kabotnet | last post by:
Hi, I'm new in db2, I'm trying to execute EXPLAIN command on some queries but i have error like: And message similar to: Token EXPLAIN is not valid, valid tokens ( END GET SET CALL DROP FREE...
1
by: w.l.fischer | last post by:
Hi, the following sequence: set current explain mode yes; set current explain snapshot yes; update ...; set current explain mode no;
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
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?

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.