473,471 Members | 1,858 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Huge estimated cost for a simple delete statement with cascade

Hi,

I have a table (TAB1) withi has 4 child tables on COL1 with DELETE
CASCADE.

When I delete any row in TAB1, it will delete corresponding rows on
all child tables.

SQL : delete from TAB1 where COL1 = 21

Explain shows the following :

Estimated Cost = 164650096.000000
Estimated Cardinality = 6440161.000000

Can anybody help me in tuning this please ?
Nov 12 '05 #1
3 4403
ku***@tumkurcity.com (Kumar) wrote in message news:<2f**************************@posting.google. com>...
Hi,

I have a table (TAB1) withi has 4 child tables on COL1 with DELETE
CASCADE.

When I delete any row in TAB1, it will delete corresponding rows on
all child tables.

SQL : delete from TAB1 where COL1 = 21

Explain shows the following :

Estimated Cost = 164650096.000000
Estimated Cardinality = 6440161.000000

Can anybody help me in tuning this please ?


Unless you run detailed stats against all the tables involved using
the runstats command, DB2 may not know how many rows match that value
in the child tables. Check the Command Reference manual to see what
syntax is needed for capturing the most detailed information possible
on the foreign key columns in the child tables.
Nov 12 '05 #2
Leo
Is col1 the primary key?
Are stats up to date?
Do you have indexes on the foreign keys?
Can you post the access plan and not just the cost estimates?
How many child records exists for each parent record?

ku***@tumkurcity.com (Kumar) wrote in message news:<2f**************************@posting.google. com>...
Hi,

I have a table (TAB1) withi has 4 child tables on COL1 with DELETE
CASCADE.

When I delete any row in TAB1, it will delete corresponding rows on
all child tables.

SQL : delete from TAB1 where COL1 = 21

Explain shows the following :

Estimated Cost = 164650096.000000
Estimated Cardinality = 6440161.000000

Can anybody help me in tuning this please ?

Nov 12 '05 #3
YES...COL1 is the primary key.
YES...STATS are up-to-date.
NO...not all tables ahve indexes defined on these foreign columns ,
however, there are only very few records on all tables..maximum 100
rows....
Nov 12 '05 #4

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

Similar topics

1
by: NotGiven | last post by:
I'd like to delete a record and all its children records at one time. How do I do that? Can you, in one SQL statement, delete from table 1 where id = 3 delete from table 2 where id = 12...
4
by: Chris | last post by:
Hi, sorry to post OT but i cant find the MySQL newsgroup, however i am hoping to pick up on some expert advice from php/mysql gurus here. I'm having some trouble performing a delete across two...
1
by: Andrew DeFaria | last post by:
I created the following .sql file to demonstrate a problem I'm having. According to the manual: If |ON DELETE CASCADE| is specified, and a row in the parent table is deleted, then InnoDB...
3
by: cfxchange | last post by:
I am looking into work-arounds for what seems to be a flaw, or "undocumented feature" of SQL Server replication and Instead of Delete triggers not playing together. It seems that if you want to...
9
by: Robert Schneider | last post by:
Hi to all, I don't understand that: I try to delete a record via JDBC. But I always get the error SQL7008 with the error code 3. It seems that this has something to do with journaling, since the...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
3
by: Tim Marshall | last post by:
HI all, Access 2003, Jet back end. Rather than annoy my users in a particular app by having relationships with enforced relational integrity refuse to delete a record with related records, I'm...
3
by: hilz | last post by:
Hi all I am trying to create a relation between two tables. this is the sql statement in question alter table T1 add constraint relation_T1_to_T2 foreign key (T2_ID) references T2 (ID) on...
3
by: John Rivers | last post by:
Hello, I think this will apply to alot of web applications: users want the ability to delete a record in table x this record is related to records in other tables and those to others in...
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...
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...
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: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.