473,472 Members | 2,264 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

cluster

Hi,

The application I work on has a table created with a clustered index. A
stored procedure that updates this table is then created while the
table is empty. As i understand it, the access plan for the stored
procedure is determined when the stored procedure is created/compiled.
Due to the table being empty, DB2 creates an access plan where a
tablescan is used to find the correct row to update. However, as the
table grows these updates will be slower and slower as the tablescan
becomes more expensive. What we really want is to use the clustered
index. Then updates will be consistently fast.

If RUNSTATS is run later on this table and index (when the table has
data in it) and the stored procedure is rebound
(SYSPROC.REBIND_ROUTINE_PACKAGE(...)), then an access plan is created
that uses the clustered index. And updates will be improved as the
clustered index is used in the update.

What i would like to know is, is there any way to create a clustered
index so that its cluster ratio is high, and is always used in the
access plan? Is there any way to force a clustered index to be used on
an empty table?

Thanks
Otto

Dec 2 '05 #1
6 1689
Just a guess, in the routine add DYNAMIC RESULT SETS <number of
expected records> or in the query use OPTIMIZE FOR <number of expected
records> ROWS.

B.

Dec 2 '05 #2
Ian
Otto wrote:
Hi,

The application I work on has a table created with a clustered index. A
stored procedure that updates this table is then created while the
table is empty. As i understand it, the access plan for the stored
procedure is determined when the stored procedure is created/compiled.
Due to the table being empty, DB2 creates an access plan where a
tablescan is used to find the correct row to update. However, as the
table grows these updates will be slower and slower as the tablescan
becomes more expensive. What we really want is to use the clustered
index. Then updates will be consistently fast.

If RUNSTATS is run later on this table and index (when the table has
data in it) and the stored procedure is rebound
(SYSPROC.REBIND_ROUTINE_PACKAGE(...)), then an access plan is created
that uses the clustered index. And updates will be improved as the
clustered index is used in the update.

What i would like to know is, is there any way to create a clustered
index so that its cluster ratio is high, and is always used in the
access plan? Is there any way to force a clustered index to be used on
an empty table?


The cluster ratio is an indication of how well the data in the *table*
is ordered with respect to an index. So, if your table has no data,
the cluster ratio is NULL. If your table has 1 row, the cluster ratio
is 1 (100%)!

Now, you can tell DB2 that a table's cardinality changes drastically,
(ALTER TABLE ... VOLATILE CARDINALITY), which will influence the
optimizer to choose the index.

However, if your problem arises because the table has 0 rows initially
(but this never does again), then this is really a question of ensuring
that you have adequate maintenance procedures set up. i.e. periodic
RUNSTATS/REBIND.

Dec 2 '05 #3
You can manually update (set) the statistics for the table and the index
before binding the stored procedure. Your statistics will be used to
determine the access path.

Statistics values are interrelated and and should be consistant. The
easiest way to do this is to use db2look to dump the statistics from a
populated table and use them to set the statistics for a new table.

Phil Sherman
Otto wrote:
Hi,

The application I work on has a table created with a clustered index. A
stored procedure that updates this table is then created while the
table is empty. As i understand it, the access plan for the stored
procedure is determined when the stored procedure is created/compiled.
Due to the table being empty, DB2 creates an access plan where a
tablescan is used to find the correct row to update. However, as the
table grows these updates will be slower and slower as the tablescan
becomes more expensive. What we really want is to use the clustered
index. Then updates will be consistently fast.

If RUNSTATS is run later on this table and index (when the table has
data in it) and the stored procedure is rebound
(SYSPROC.REBIND_ROUTINE_PACKAGE(...)), then an access plan is created
that uses the clustered index. And updates will be improved as the
clustered index is used in the update.

What i would like to know is, is there any way to create a clustered
index so that its cluster ratio is high, and is always used in the
access plan? Is there any way to force a clustered index to be used on
an empty table?

Thanks
Otto

Dec 2 '05 #4
"Ian" <ia*****@mobileaudio.com> wrote in message
news:43**********@newsfeed.slurp.net...
Now, you can tell DB2 that a table's cardinality changes drastically,
(ALTER TABLE ... VOLATILE CARDINALITY), which will influence the
optimizer to choose the index.


Ian has the correct answer above. Try this first before doing anything else.
Dec 2 '05 #5
Phil Sherman wrote:
You can manually update (set) the statistics for the table and the index
before binding the stored procedure. Your statistics will be used to
determine the access path.

Statistics values are interrelated and and should be consistant. The
easiest way to do this is to use db2look to dump the statistics from a
populated table and use them to set the statistics for a new table.

Phil Sherman
Otto wrote:
Hi,

The application I work on has a table created with a clustered index. A
stored procedure that updates this table is then created while the
table is empty. As i understand it, the access plan for the stored
procedure is determined when the stored procedure is created/compiled.
Due to the table being empty, DB2 creates an access plan where a
tablescan is used to find the correct row to update. However, as the
table grows these updates will be slower and slower as the tablescan
becomes more expensive. What we really want is to use the clustered
index. Then updates will be consistently fast.

If RUNSTATS is run later on this table and index (when the table has
data in it) and the stored procedure is rebound
(SYSPROC.REBIND_ROUTINE_PACKAGE(...)), then an access plan is created
that uses the clustered index. And updates will be improved as the
clustered index is used in the update.

What i would like to know is, is there any way to create a clustered
index so that its cluster ratio is high, and is always used in the
access plan? Is there any way to force a clustered index to be used on
an empty table?

Thanks
Otto

Further more you can use the REOPT bind options to have DB2 wait with
the compilation for the first execution (ONCE) or recompile for every
execution (ALWAYS).
Use the SET_ROUTINE_OPTS() procedure to pick your bind options prior to
procedure creation.

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Dec 3 '05 #6
Serge Rielau wrote:
Phil Sherman wrote:
You can manually update (set) the statistics for the table and the
index before binding the stored procedure. Your statistics will be
used to determine the access path.

Statistics values are interrelated and and should be consistant. The
easiest way to do this is to use db2look to dump the statistics from a
populated table and use them to set the statistics for a new table.

Phil Sherman
Otto wrote:
Hi,

The application I work on has a table created with a clustered index. A
stored procedure that updates this table is then created while the
table is empty. As i understand it, the access plan for the stored
procedure is determined when the stored procedure is created/compiled.
Due to the table being empty, DB2 creates an access plan where a
tablescan is used to find the correct row to update. However, as the
table grows these updates will be slower and slower as the tablescan
becomes more expensive. What we really want is to use the clustered
index. Then updates will be consistently fast.

If RUNSTATS is run later on this table and index (when the table has
data in it) and the stored procedure is rebound
(SYSPROC.REBIND_ROUTINE_PACKAGE(...)), then an access plan is created
that uses the clustered index. And updates will be improved as the
clustered index is used in the update.

What i would like to know is, is there any way to create a clustered
index so that its cluster ratio is high, and is always used in the
access plan? Is there any way to force a clustered index to be used on
an empty table?

Thanks
Otto

Further more you can use the REOPT bind options to have DB2 wait with
the compilation for the first execution (ONCE) or recompile for every
execution (ALWAYS).
Use the SET_ROUTINE_OPTS() procedure to pick your bind options prior to
procedure creation.

Cheers
Serge

REOPT doesn't work unless you execute RUNSTATS to alter the statistics.
I've worked on systems where an empty table at the start of the business
day has enough rows in it after a couple of hours to make using an index
a much better performer than a scan.

Phil Sherman
Dec 5 '05 #7

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

Similar topics

2
by: Leonardo C | last post by:
Hi: I'm trying to setup a MS Cluster but I don't know if it is feasible to configure it in the way I think. I have two machines with win2k server and MSSQL-2000 one of them is currently...
0
by: williams | last post by:
I am trying to encrypt data in a SQLServer 2000 Cluster using Microsoft EFS. I have successfully encrypted a standalone DB but we are having difficulty with the Cluster. I am only encrypting the...
1
by: richardshen | last post by:
DB2 V8 on windows 2003 cluster server. DB2MSCS -f:db2.cfg DB2 instance is in the cluster now. DB2MSCS -u:db2 DB2 instance is in the local node now. I want to cluster the instance again DB2MSCS...
0
by: Pankajdynamic | last post by:
Hi, I've gone through couple of articles on conguring the NLB cluster using NLB Manager.Below are my queries: 1. In NLB Manager, Cluster Parameter tab, - Can I give any IP address for Cluster...
17
by: Peter Ericsson | last post by:
Does anyone know if Microsoft plans to implement an C# (.net) API for MS Cluster like the one in C++? Or has someone else written a C# wrapper for the C++ API?
4
by: ThunderMusic | last post by:
Hi, We have many servers setup as a cluster. When one server crashes, another one take the relay... We want to know if it's possible (I suppose it is) to make a Windows service developed with .NET...
3
by: Simon | last post by:
Hi All, I'm hoping someone will have some words of wisdom for me regarding MS Clustering on Windows 2003. I have a service that runs on a cluster. During invocation it's supposed to...
2
by: dunleav1 | last post by:
I have a many row and many column table that is in a 16K page size. I have four indexes on the table. I am running row compression on the table. The table does not have a primary key. The table...
1
by: =?Utf-8?B?S2Vubnk=?= | last post by:
I have one bat file that contains a command to startup Java Program. Then, I would like to create a cluster job to call the bat file. In case of one computer is down, another computer can also call...
10
by: Ian | last post by:
Henry J. wrote: MDC *guarantees* clustering, whereas a table with a clustering index will eventually require maintenance (a.k.a. reorg) to maintain the cluster ratio. That's not to say that...
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...
1
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...
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,...
1
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: 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: 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.