3 messages in com.mysql.lists.javaRE: Opimizing SQL query
FromSent OnAttachments
pras...@wipro.com15 Jun 2006 04:34 
Tim Lucia15 Jun 2006 06:02 
Jun Tang24 Jun 2006 01:25 
Subject:RE: Opimizing SQL query
From:Jun Tang (Ju@optio.com)
Date:06/24/2006 01:25:32 AM
List:com.mysql.lists.java

What type of table is this?

Assume column id is indexed, and assume list 1 is (1,2,3,4....,10000), and list
2 is (111,222.....), try this: Filter out list 2 from list 1 in your application, and get rid of 'AND list
2' from WHERE clause of your SQL statement, which reaults in the statement like
this: delete from naptrrecord where id in
(the_list_1_after_filtering_out_list_2);

Jun

________________________________

From: pras@wipro.com [mailto:pras@wipro.com] Sent: Thu 6/15/2006 7:35 AM To: ja@lists.mysql.com Subject: Opimizing SQL query

Hi,

I have a table with 1,00,000 records. I have to delete 10,000 records and the query framed is something like this : delete from naptrrecord where id in (1,2,3,4....,10000) and id not in(111,222.....);

The records that we are trying to delete are not sequential so we are sending all the IDs. This query is ver slow. Can you please give me some ideas to optimize it.

Thanks Prasad

The information contained in this electronic message and any attachments to this
message are intended for the exclusive use of the addressee(s) and may contain
proprietary, confidential or privileged information. If you are not the intended
recipient, you should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately and destroy all copies of this message and any
attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should
check this email and any attachments for the presence of viruses. The company
accepts no liability for any damage caused by any virus transmitted by this
email.

www.wipro.com