473,805 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3323
"radhika" <ra************ @hotmail.com> wrote in message
news:91******** *************** ***@posting.goo gle.com...
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*******@2muc hspam.yahoo.com > wrote in message news:<bm******* ***@hanover.tor olab.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.goo gle.com... 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_VARCHA R?

PM
Nov 12 '05 #6

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

Similar topics

0
1312
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 million records. I'm using MySQL 5.0.2. I guess I'm trying to get a better understanding of what "using index" means in the "extra" column. Here's the result of the explain on my first query: SQL-query: explain Select count(1) as counter from kbm...
14
20399
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 EXPLAIN_STATEMENT and EXPLAIN_INSTANCE exist. With VESAMPL.DDL, I loaded the predefined execution plans. In the next step, I'ld like to display the loaded access plans. So, I right clicked on "Show Explained Statements History" and got the result:
10
2161
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 like: error: Type `JTableHeader' not found in the declaration of the local variable `header'. JTableHeader header = null; To me, this indicates that the SDK isn't installed (properly). But I admit I'm pretty much a Java...
5
3640
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 actually takes 25 seconds on my computer (no other CPU intensive processes running). Is this normal for EXPLAIN ANALYZE to report a total runtime so vastly different from wall clock time? During the "explain ANALYZE delete from msgid;" the CPU is...
2
1909
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 building. The SQL's all done with placeholders, for safety and ease of twiddling, but EXPLAIN... EXPLAIN doesn't like them. Trying throws an "ERROR: there is no parameter $1" which is somewhat sub-optimal. Any way, short of hand-replacing the...
4
12732
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 our wider environment. Of course, development doesn't stop so I'm running some explain plans over some new views. The problem is, when the view is accessed as part of the explain plan script, the following error is returned.
2
1503
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 .. " update tb_xxx set ( listno ) = (select listno from tb_xxx_tmp where listno = 11 ) where listno = 11 " the explain result (use db2expln ) is amazing ... about a thousand lines !!!! ,refering all of the dozen of tables . but when i try
0
1582
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 temporary table that he uses to put the input parms into and then uses it to join against to create a dataset. When he runs explain (both visual explain, and CA's explain) it chokes on the SESSION.TABLE saying that it doesn't exist. Is there...
5
8119
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 HOLD LOCK OPEN WITH ALTER. I've created tables explain_* How can I start to find solution? Is it possible that my db2 doesn't support explain?
1
3583
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;
0
9718
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10614
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10369
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9186
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5544
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
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 we have to send another system

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.