Hi,
I have a sql procedure that (among others) deletes a row in a table
(very small). The table has a foreign key - ON DELETE NO ACTION that
points to a large table (child). There is an index defined on the child
table column, but the selectivity is very poor (actually in this
particular case all values are zero)
The delete statement looks like
delete from ParentTable_Small where primary_key = variable
Because the cascade rule is NO ACTION, DB2 will check the child table
for orphaned records (which there are none).
If I do a db2expln for a similar statement (delete from parent where
primary_key = ?) the access plan wil show a table scan of the large
table (and the deletion takes forever). However, if I replace the "?"
with a constant which is out of the child's values range, the access
plan will choose an index scan.
The stored procedure access plan shows table scan.
I tried to rebind the procedure with the REOPT ALWAYS option as well as
with the EXPLAIN option, but the explain tables show no change in the
access plan (actually the only compilation is the initial one)
Isn't this suppose to change the access plan to choose an index scan at
some point when i call the stored procedure with some actual values?
(same values for which db2expln chooses an index scan)
thanks 2 1916
Ion wrote: Hi,
I have a sql procedure that (among others) deletes a row in a table (very small). The table has a foreign key - ON DELETE NO ACTION that points to a large table (child). There is an index defined on the child table column, but the selectivity is very poor (actually in this particular case all values are zero) The delete statement looks like
delete from ParentTable_Small where primary_key = variable
Because the cascade rule is NO ACTION, DB2 will check the child table for orphaned records (which there are none).
If I do a db2expln for a similar statement (delete from parent where primary_key = ?) the access plan wil show a table scan of the large table (and the deletion takes forever). However, if I replace the "?" with a constant which is out of the child's values range, the access plan will choose an index scan.
The stored procedure access plan shows table scan. I tried to rebind the procedure with the REOPT ALWAYS option as well as with the EXPLAIN option, but the explain tables show no change in the access plan (actually the only compilation is the initial one)
Isn't this suppose to change the access plan to choose an index scan at some point when i call the stored procedure with some actual values? (same values for which db2expln chooses an index scan)
thanks
Which fixpack are you on? Note that when you recompile the procedure you
won't see the reoptimized plan (yet).
It should show up when you execute the procedure assuming you have
EXPLAIN ALL set.
Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Hi Serge,
DB21085I Instance "DB2" uses "32" bits and DB2 code release "SQL08021"
with
level identifier "03020106".
Informational tokens are "DB2 v8.1.8.762", "s041221", "WR21348", and
FixPak "8".
After recompiling the stored procedure, explaining the package shows a
table scan.
When executing it, it obviously stays with the table scan as it takes
forever.
However, if in the procedure I replace the delete statement with
either:
delete from table where pk=666
or i make it dynamic sql with hardcode values instead of parameter
markers, the stored procedure executes instantly This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mike J |
last post by:
I have several stored procedures that run fine from my SQL Server
database (via the exec command.), though when I call these procedures
from my web application, they do not complete. I have other...
|
by: serge |
last post by:
How can i delete all user stored procedures and all table triggers very fast
in
a single database?
Thank you
|
by: BlueDragon |
last post by:
The place where I work is moving to MS SQL Server from Lotus Notes. I
have done a lot of coding in Lotus Notes, and have, I suppose,
intermediate skills in basic SQL -- queries, insert, updates,...
|
by: Rhino |
last post by:
I've spent the last couple of hours trying to figure out how to debug a Java
stored procedure and am just going in circles. The last straw came when I
got "Cannot open input stream for default"...
|
by: esmith2112 |
last post by:
We all of a sudden find ourselves in dire straits, because we have one
of those mysteries where everything used to work, and apparently, all
of a sudden everything went to pot just in time for a...
|
by: Tim Marshall |
last post by:
I was following the thread "Re: Access Treeview - Is it Safe Yet?" with
interest and on reading the post describing Lauren Quantrell's
SmartTree, I've run into something I don't understand: Stored...
|
by: R Millman |
last post by:
under ASP.NET, single stepping in debug mode appears not
to stop within event procedures. i.e. 1) Create web page
with submit button and event procedure for the click
event in the code behind...
|
by: kanda |
last post by:
Hello.
I am developing the application (VBA&ODBC, to be exact) which
periodically calls the stored procedures in the IBM DB2. A few of the
procedures require executing with isolation level RR (...
|
by: Andrew Wan |
last post by:
I have been developing web applications with ASP & Javascript for a long
time. I have been using Visual Studio 2003.NET. While VS2003 is okay for
intellisense of ASP & Javascript, it's still not...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
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...
|
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: 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...
| |