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

Temporary index is not taking in the Stored procedure

Hi All

I am using a Global Temporary table in the Stored procedure and i am
creating index for a column in that temporary table.When i am executing
it. It is not taking that index. I checked using explain plan. But if i
run the runstats in the CLP for that temporary table it is taking the
index. How i have to implement in the Stored procedure itself?
Warm Regards
Guru

Nov 12 '05 #1
4 3847
"Guru" <gu*********@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Hi All

I am using a Global Temporary table in the Stored procedure and i am
creating index for a column in that temporary table.When i am executing
it. It is not taking that index. I checked using explain plan. But if i
run the runstats in the CLP for that temporary table it is taking the
index. How i have to implement in the Stored procedure itself?
Warm Regards
Guru

After creating the Global Temporary table, use the following command to
encourage index usuage:

ALTER TABLE table-name VOLATILE;
Nov 12 '05 #2
Guru wrote:
Hi All

I am using a Global Temporary table in the Stored procedure and i am
creating index for a column in that temporary table.When i am executing
it. It is not taking that index. I checked using explain plan. But if i
run the runstats in the CLP for that temporary table it is taking the
index. How i have to implement in the Stored procedure itself?
Warm Regards
Guru

I can only think of two reasons:
* If you create the index after the query is run the first time it won't
be picked up in later runs since adding an index does not invalidate
existing palns.

* WHen you try from CLP do you use constants where the query in the
procedure used variables? That would change the query sufficiently to
get a different plan. Use parameter markers in CLP (with a CAST(? AS
<variabletype>) if needed to compare apples to apples.
If that turns out to be the difference you can experiment with the
SELECTIVITY clause on the predicates to increase the filter factor or
you can use the REOPT(ONCE) prep option to use the varibale values on
first run to determine filtering.
In DB2 V8.2 I think there is a stored procedure to set the prep options
for SQL Procedures.

Cheers
Serge
Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #3
Thanks for ur response...

We cannot use the DDL commands on the Temporary tables....

Warm Regards
Guru
Mark A wrote:
"Guru" <gu*********@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Hi All

I am using a Global Temporary table in the Stored procedure and i am creating index for a column in that temporary table.When i am executing it. It is not taking that index. I checked using explain plan. But if i run the runstats in the CLP for that temporary table it is taking the index. How i have to implement in the Stored procedure itself?
Warm Regards
Guru
After creating the Global Temporary table, use the following command

to encourage index usuage:

ALTER TABLE table-name VOLATILE;


Nov 12 '05 #4
Be specified in an ALTER, COMMENT, GRANT, LOCK, RENAME or REVOKE
statement (SQLSTATE 42995).

Nov 12 '05 #5

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

Similar topics

2
by: Calista | last post by:
I have a stored procedure that creates a temporary table. If two people (using the same account) execute the same stored procedure at the same time, will they overwrite / access the temporary...
4
by: tperovic | last post by:
If a stored procedure invokes another stored procedure that creates a temporary table why can't the calling procedure see the temporary table? CREATE PROCEDURE dbo.GetTemp AS CREATE TABLE...
11
by: randi_clausen | last post by:
Using SQL against a DB2 table the 'with' key word is used to dynamically create a temporary table with an SQL statement that is retained for the duration of that SQL statement. What is the...
7
by: Mike Hubbard | last post by:
I have read many many messages about temporary tables and stored procedures. Still, I am struggling with a simple concept. I have a java program which creates a temporary table. I now want to...
3
by: pinney.colton | last post by:
I would like to create a stored procedure which creates a temp table to store some XML. The # of fields of XML is dependent upon the contents of another table in the application, so the first part...
3
by: comp_databases_ms-sqlserver | last post by:
This post is related to SQL server 2000 and SQL Server 2005 all editions. Many of my stored procedures create temporary tables in the code. I want to find a way to find the query plan for these...
3
by: Otto Carl Marte | last post by:
Hi, As I understand it, Declared Global Temporary Tables (DGTTs) have a scope that is session/connection based. Using the same connection, I have discovered that if I declare a DGTT in one...
5
by: Rahul B | last post by:
Hi, I have very little knowledge about creating Procedures/functions in DB2. When i tried to create the test function like CREATE FUNCTION GET_TEST (P_TEST_ID INTEGER, P_SEL_OR_SORT...
1
by: rdsandy | last post by:
Hi, I have a table Risk, a table Mitigation and a table RiskArchive. I am taking the RiskID, Criticality and MitigationPlan fields from Risk, and MitigationActionID from Mitigation and inserting...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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 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.