473,725 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why DELETE takes longer than INSERT?

I'm running an ISP database in SQL 6.5 which has a table 'calls'. When the
new month starts I create a new table with the same fields and move the data
of previous month into that table and delete it from calls. So 'calls' holds
the data of only the current month. for example at the start of november
2003 I ran the queries

Create Table Oct2003Calls {
............... .
............... .

}

/* Now insert data of october into new table */

INSERT Oct2003Calls

SELECT *
FROM calls
WHERE calldate < '11/1/03'
/* Finaly delete october data from calls table */

DELETE FROM calls
WHERE calldate < '11/1/03'

The problem is that while the insert query takes about 2 minutes to execute
the delete queries takes over 10 minutes to affect the same no. of rows. Why
is that?
This causes problems because user authentication stops when this query is
running which means users cant connect to the internet.


Jul 20 '05 #1
4 2789
On Mon, 3 Nov 2003 12:51:20 +0500, "MAB71" <b1*********@ya hoo.com>
wrote:
I'm running an ISP database in SQL 6.5 which has a table 'calls'. When the
new month starts I create a new table with the same fields and move the data
of previous month into that table and delete it from calls. So 'calls' holds
the data of only the current month. for example at the start of november
2003 I ran the queries

Create Table Oct2003Calls {
.............. .
.............. .

}

/* Now insert data of october into new table */

INSERT Oct2003Calls

SELECT *
FROM calls
WHERE calldate < '11/1/03'
/* Finaly delete october data from calls table */

DELETE FROM calls
WHERE calldate < '11/1/03'

The problem is that while the insert query takes about 2 minutes to execute
the delete queries takes over 10 minutes to affect the same no. of rows. Why
is that?
This causes problems because user authentication stops when this query is
running which means users cant connect to the internet.

Difficult to be sure, but some thoughts;

There are other tables referencing this one and a delete here is
cascading,

This table has a delete trigger on it (perhaps for auditing purposes)

RI is being checked

This table is indexed and other one isn't, or the number of indexes is
different.

Jul 20 '05 #2
Open up query analyzer, select view execution plan, and run your code.
It will tell you exactly what sql is doing. Taking a shot in the
dark, the table probably needs an index.
Jul 20 '05 #3
Bo
here's an idea to make your table maintenance a bit easier:

Assuming your really must keep data for each month in its own table, why
not put an trigger on CALLS table, and in the trigger select datepart of
current date. Then a case statement, which examines the result of datapart.
When = 01 insert new row into Jan2003Calls, When = 02 insert new row into
Feb2003Calls, etc. Then run a daemon which deletes from CALLS every 5
minutes, so it never loads up.
"MAB71" <b1*********@ya hoo.com> wrote in message
news:bo******** *****@ID-31123.news.uni-berlin.de...
I'm running an ISP database in SQL 6.5 which has a table 'calls'. When the
new month starts I create a new table with the same fields and move the data of previous month into that table and delete it from calls. So 'calls' holds the data of only the current month. for example at the start of november
2003 I ran the queries

Create Table Oct2003Calls {
...............
...............

}

/* Now insert data of october into new table */

INSERT Oct2003Calls

SELECT *
FROM calls
WHERE calldate < '11/1/03'
/* Finaly delete october data from calls table */

DELETE FROM calls
WHERE calldate < '11/1/03'

The problem is that while the insert query takes about 2 minutes to execute the delete queries takes over 10 minutes to affect the same no. of rows. Why is that?
This causes problems because user authentication stops when this query is
running which means users cant connect to the internet.


Jul 20 '05 #4
lol ... n1 Bo. Didnt realise MS Developers had a sense of humour, but
htats the best joke Ive read all day. Except the one about the hippo
eating the dwarf...
"Bo" <no@thank.you > wrote in message news:<3f******* ***@newspeer2.t ds.net>...
here's an idea to make your table maintenance a bit easier:

Assuming your really must keep data for each month in its own table, why
not put an trigger on CALLS table, and in the trigger select datepart of
current date. Then a case statement, which examines the result of datapart.
When = 01 insert new row into Jan2003Calls, When = 02 insert new row into
Feb2003Calls, etc. Then run a daemon which deletes from CALLS every 5
minutes, so it never loads up.

Jul 20 '05 #5

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

Similar topics

13
1742
by: Axel Panning | last post by:
Hallo, ich hab bei einem Programm bei mir festgestellt, daß das "deleten" von Feldern erheblich länger dauert, als das Anlegen von Feldern. p. Bei einem Programm von mir werden oft große Datenfelder unterschiedlicher Größe angelegt und wieder gelöscht. Daher ist dieser Umstand sehr ungünstig. Ist das Normal, daß der Unterschied bei Faktor 10-20 liegt? Oder begehe ich hier an irgendeiner Stelle einen grundlegenden Fehler!?
2
11326
by: kumar | last post by:
we are trying to delete data from a huge 75 million records table it takes 4hr to prune data delete from Company where recordid in (select top 10000 recordid from recordid_Fed3 where flag = 0) we have a loop that prunes 10000 records at a time in a while loop let me know if there is a better way to acheive this
3
2102
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 other tables etc. in other words we must use cascade delete to do
3
13746
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum. Everyone wants to do a java confirmation box when a user clicks the delete button. Fair enough, basic user design rules state that you should always confirm a delete action. There is also a consensus that the best way to do this is a template...
3
1439
by: sarathy | last post by:
Hi, Need a clarification wrt new and delete operators. Consider the 2 code snippets. 1. { Object *obj = new Object(); .... obj->method1();
22
4187
by: Cylix | last post by:
I have a 4row x 1col table, I would like to drop all the content of row three. Since Mac IE5.2 does not suppport deleteRow method, I have also try to set the innerHTML=''; but it does not work. How can I delete the node from DOM in other way? Thanks.
33
5562
by: desktop | last post by:
In the C++ standard sec 23.1.2 table 69 it says that erase(q) where q is a pointer to an element can be done in amortized constant time. I guess that is not worst case since std::set is practically a red-black tree where insert/delete takes O(lg n) time. Or are there some other explanation for this complexity?
1
4094
watertraveller
by: watertraveller | last post by:
Hi all. My ultimate goal is to return two columns, where no single value appears anywhere twice. This means that not only do I want to check that nothing from column A appears in column B and vice-versa, but I also don't want the same value appearing twice in A and twice in B. So far I have: --Diff the columns INSERT INTO @Table SELECT One, Two FROM @Column1 a FULL OUTER JOIN @Column2 b
1
8326
by: ChrisC | last post by:
Hello, I am attempting to create a trigger to keep track of changes to a table, mainly about specific changes to the data in the table. I had hoped that triggers defined as for each row would actually run as each row was deleted, but it appears that it is fired, once for each row, after the entire delete statement has completed. Is this expected? Here is some DDL/DML that will demonstrate what I'm trying to do - and what the...
0
8752
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9176
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9113
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8097
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2635
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.