RE: Opimizing SQL query
"Jun Tang" <[email protected]>
| Newsgroups | gmane.comp.db.mysql.java |
|---|---|
| Message-ID | <[email protected]> |
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: [email protected] [mailto:[email protected]] Sent: Thu 6/15/2006 7:35 AM To: [email protected] 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