hi, we are using db2 udb v8.1 on windows, if i have a query use where
clause where key > value, the explain sql gives me access path is
table scan, but if i do key = value, it uses index scan, so how can i
force db2 to use index scan when key > value to makes the query run
faster? 4 6260
xixi wrote: hi, we are using db2 udb v8.1 on windows, if i have a query use where clause where key > value, the explain sql gives me access path is table scan, but if i do key = value, it uses index scan, so how can i force db2 to use index scan when key > value to makes the query run faster?
Unless your stats are wrong (or if you haven't collected distribution
stats), the DB2 Optimizer is usually pretty smart about what is better.
If your predicate key > value matches 90% of the table, it's not likely
that DB2 will perform an index scan AND then scan the table, unless you
are looking only for columns that exist in the index.
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
"xixi" <da****@yahoo.com> wrote in message
news:c0**************************@posting.google.c om... hi, we are using db2 udb v8.1 on windows, if i have a query use where clause where key > value, the explain sql gives me access path is table scan, but if i do key = value, it uses index scan, so how can i force db2 to use index scan when key > value to makes the query run faster?
Make sure you have run runstats with distribution on key columns and index
all.
DB2 will use an index "IF" it can avoid reading some 4K data pages (or what
ever the page size is) in the table. But if there is at least 1 qualifying
row on each data page, it usually will not be any fast to use an index
because DB2 does I/O one page at a time. If the row size is 100 bytes, there
are 40 rows on each data page.
If you cluster the table on the index in question, that will likely cause
the index to be used for a > predicate. Or you can just reorg on that index
and then do runstats. da****@yahoo.com (xixi) wrote in message news:<c0**************************@posting.google. com>... hi, we are using db2 udb v8.1 on windows, if i have a query use where clause where key > value, the explain sql gives me access path is table scan, but if i do key = value, it uses index scan, so how can i force db2 to use index scan when key > value to makes the query run faster?
if you really wish to _force_, try OPTIMIZE FOR FIRST clause, or use SELECTIVITY
Use db2batch to see if the query runs faster. Please post the results
Xixi, once you´ve checked the other possibilities, and all is ok
including your index (your key is the first column within the index,
isn´t it?), you may set the table to volatile.
This forces the optimizer to use an index rather than doing a table scan.
Stefan
xixi schrieb: hi, we are using db2 udb v8.1 on windows, if i have a query use where clause where key > value, the explain sql gives me access path is table scan, but if i do key = value, it uses index scan, so how can i force db2 to use index scan when key > value to makes the query run faster? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Carlos Moreno |
last post by:
I can't find a reasonable explanation for this.
I have a table game, with primary key gameid (an int).
If I use a where involving gameid and <, or >, or <=,
or >=, then I get a sequential...
|
by: Gerard M. Operana |
last post by:
unsubscribe
|
by: Sean C. |
last post by:
Helpful folks,
Most of my previous experience with DB2 was on s390 mainframe systems
and the optimizer on this platform always seemed very predictable and
consistent. Since moving to a WinNT/UDB...
|
by: Gorilla |
last post by:
I bound my package with EXPLAIN(YES), and it's got the following static
SQL in it:
EXEC SQL SELECT CARDF, RECLENGTH
INTO :CARDF,:RECLENGTH
FROM SYSIBM.SYSTABLES
WHERE NAME = :TBNAME
AND...
|
by: Pavel Stehule |
last post by:
Hello,
Pg make query 1. and 2. very fast (use index), but for query 3. dont use
index. I can solve its using select union, but I readed so pg 7.5 don't
problem with OR operator. I use cvs pg. I...
| |
by: Mike Wertheim |
last post by:
Hi,
I'm using PostgreSQL 8.
I have two tables that I am doing a join on, and the join executes very
slowly.
The table called Notification has a text field called NotificationID,
which is...
|
by: bobby_b_ |
last post by:
I have a table where fields 1 and 2 make up the primary key.
Because of this, I have a unique composite index on fields 1 and 2 (as
required by DB2). Now my question is: Fields 1 and 2 are also...
|
by: BD |
last post by:
Hi, all.
My background is more Oracle than db2. My skills at SQL tuning are
quite limited.
I'm running 8.2 on Windows.
I'm tasked with some SQL optimization, and am doing some explain plans...
|
by: Steffen Stellwag |
last post by:
Truely is often better to scan a table in full passing by an index ,
but if you can force the optimizer to use an index via a hint for
testing and comparing the results.
But the index in the...
|
by: Henry J. |
last post by:
I have a composite index on two columns in a table. However, the
index is not used in a query that restricts the 2nd column to a
constant. If both columns are linked with columns in other join...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
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: 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...
| |
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...
|
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...
| |