Article View: borland.public.interbase.opensource
Article #359Re: Really Slow Delete on an System
From: Bill Todd
Date: Mon, 08 Nov 2004 19:49
Date: Mon, 08 Nov 2004 19:49
40 lines
2308 bytes
2308 bytes
The problem is that the subquery has to scan the entire table sequentially without using an index and the delete has to scan the 3500 rows returned by the subquery for each row in the table you are deleting from. One thing that will help is to use a stored procedure with a FOR SELECT to replace the subquery and the DELETE in the DO clause of the FOR SELECT. Make sure WipNo is indexed. For even better performance convert the inqDate column to type DATE or add a shadow column that stores the date as type DATE and update the shadow value automatically with a trigger. -- Bill (TeamB) TeamB cannot answer questions received via email Jarek Bialik wrote: > Hi Bill, thanks for your response, > > Unfortunately that "date" column is actually stored as Varchar(10), > so it needs a type cast. The Select will return about ~3500 rows. > > So does the subquery execute for every row in the delete query? > Shouldnt the select sub query execute only once? > > Thanks > Jarek Bialik > Britec Computer Consultanting > "Bill Todd" <no@no.com> wrote in message > news:418c1939$1@newsgroups.borland.com... > > Why do you need to cast the value from the inqDate column? What is > > its data type? > > > > How many rows does the SELECT return? > > > > -- > > Bill (TeamB) > > TeamB cannot answer questions received via email
Technical Details
Message-ID:
<418fdbc7@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!border2.nntp.ams.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<418c133c$1@newsgroups.borland.com> <418c1939$1@newsgroups.borland.com> <418fa654@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 106772,edefe87e3c53cf5d X-Google-Attributes: gid106772,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Bill Todd" <no@no.com> Subject: Re: Really Slow Delete on an System Newsgroups: borland.public.interbase.opensource References: <418c133c$1@newsgroups.borland.com> <418c1939$1@newsgroups.borland.com> <418fa654@newsgroups.borland.com> Organization: The Database Group, Inc. User-Agent: XanaNews/1.16.4.6 NNTP-Posting-Host: 216.207.211.19 Message-ID: <418fdbc7@newsgroups.borland.com> Date: 8 Nov 2004 12:49:11 -0700 X-Trace: newsgroups.borland.com 1099946951 216.207.211.19 (8 Nov 2004 12:49:11 -0700) Lines: 40 Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!border2.nntp.ams.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail