473,397 Members | 2,068 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,397 software developers and data experts.

my query is a bit slow....

Hi Gurus

I have the following query:

DELETE ITEM.*
FROM ITEM
LEFT JOIN EXTRA_DETAILS ON
ITEM.item_code = EXTRA_DETAILS.object_code
WHERE EXTRA_DETAILS.field_value IS NULL;

ITEM has about 10,000 records in it and EXTRA_DETAILS has about 30,000
items in it. There are about 2,000 matches.

What I am trying to achieve is to delete all the records from ITEM that
do not have a match in EXTRA_DETAILS

For some reason the query takes like about 60 seconds to process.

I have added an index to EXTRA_DETAILS.object_code (int(12) and
ITEM.item_code is the primary index of ITEM (also int(12).

Any recommendations greatly appreciated.

Thanks a million

Nicolaas

Dec 2 '06 #1
2 2214

How's the performance when you use a subquery for example...

DELETE FROM Item WHERE item_code IN (SELECT object_code FROM
EXTRA_DETAILS WHERE field_value IS NULL);
windandwaves wrote:
Hi Gurus

I have the following query:

DELETE ITEM.*
FROM ITEM
LEFT JOIN EXTRA_DETAILS ON
ITEM.item_code = EXTRA_DETAILS.object_code
WHERE EXTRA_DETAILS.field_value IS NULL;

ITEM has about 10,000 records in it and EXTRA_DETAILS has about 30,000
items in it. There are about 2,000 matches.

What I am trying to achieve is to delete all the records from ITEM that
do not have a match in EXTRA_DETAILS

For some reason the query takes like about 60 seconds to process.

I have added an index to EXTRA_DETAILS.object_code (int(12) and
ITEM.item_code is the primary index of ITEM (also int(12).

Any recommendations greatly appreciated.

Thanks a million

Nicolaas
Dec 5 '06 #2

Peter wrote:
How's the performance when you use a subquery for example...

DELETE FROM Item WHERE item_code IN (SELECT object_code FROM
EXTRA_DETAILS WHERE field_value IS NULL);

Hi Peter

I will give that a go. Thank you

Dec 6 '06 #3

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

Similar topics

2
by: Tim Fountain | last post by:
We've recently enabled slow query logging on a server and it's proving interesting seeing which queries are bogging things down. This one is puzzling me a little: SELECT articleid, type,...
5
by: Jason | last post by:
The following stored procedure is taking too long (in my opinion). The problem seems to be the SUM line. When commented out the query takes a second or two. When included the response time climbs...
1
by: Gary Wales | last post by:
We have two main query types running against a table of some 2 million rows and have gotten query response down to well under a second by using the right indexes. Problem is that we are running...
1
by: Thomas Bartkus | last post by:
Is it possible that the elapsed time being measured includes waiting for the client to acknowledge that it has received all the data? In *addition* to the server execution time? Documentation...
7
by: Thomi Baechler | last post by:
Hello Everybody I run the following query against to identical databases. Execution time on the first DB is 0 seconds, on the other 6 seconds! SELECT dbo.HRMABZ.EMPKEY ,...
2
by: AG | last post by:
I am able to run a query which runs FAst in QA but slow in the application.It takes about 16 m in QA but 1000 ms on the Application.What I wanted to know is why would the query take a long time...
3
by: Janross | last post by:
I'm having trouble with a query that's prohibitively slow. On my free-standing office computer it's fine (well, 2-4 seconds), but on the client's network, it takes at least 5 minutes to run. ...
4
by: cefrancke | last post by:
Are there any ways to speed up a Cumulative sum in a query or perhaps another faster way to have a cumulative sum column (call a vba function?). For example, I want to sum up all values under...
0
by: Dave Hammond | last post by:
Hi All, I'm trying to use the slow-query-log (with --log-queries-not-using-indexes enabled) to determine if any queries need optimization, and have a few questions about some entries I'm...
2
by: existential.philosophy | last post by:
This is a new problem for me: I have some queries that open very slowly in design view. My benchmark query takes about 20 minutes to open in design view. That same query takes about 20 minutes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
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
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...
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
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...

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.