If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Extremely slow executing of a query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-01-03, 12:39
Mike Borozdin Mike Borozdin is offline
Registered User
 
Join Date: Sep 2003
Location: St.Petersburg, Russia
Posts: 19
Question Extremely slow executing of a query

Hello!

My client has a MySQL table with 38594 entries. And I need to remove all the duplicates, these duplicates have the equal value in the 'lyrics_file' field. So, to get a list of duplicates I execute this query:


Code:
SELECT l1.lyrics_id FROM lyrics AS l1, lyrics AS l2
WHERE l1.lyrics_file = l2.lyrics_file AND l1.lyrics_id != l2.lyrics_id
But it takes ages to permorm it. Is there any ways to get a list of duplicates or even to remove them by using only one query. Please, note that I shouldn't remove all lyrics with the same file, I should leave one, so if I have the following entries:

Code:
lyrics_id | lyrics_name | lyrics_file
26274	 | Bringin' On the Heartbreak | Bringin-On-The-Heartbreak
47485	 | Bringin On the Heartbreak  | Bringin-On-The-Heartbreak
I should leave one of them, no matter which one.

Thanks in advance!
Reply With Quote
  #2 (permalink)  
Old 12-01-03, 14:24
bstjean bstjean is offline
Registered User
 
Join Date: Sep 2002
Location: Montreal, Canada
Posts: 219
Re: Extremely slow executing of a query

Quote:
Originally posted by Mike Borozdin
Hello!

My client has a MySQL table with 38594 entries. And I need to remove all the duplicates, these duplicates have the equal value in the 'lyrics_file' field. So, to get a list of duplicates I execute this query:


Code:
SELECT l1.lyrics_id FROM lyrics AS l1, lyrics AS l2
WHERE l1.lyrics_file = l2.lyrics_file AND l1.lyrics_id != l2.lyrics_id
But it takes ages to permorm it. Is there any ways to get a list of duplicates or even to remove them by using only one query. Please, note that I shouldn't remove all lyrics with the same file, I should leave one, so if I have the following entries:

Code:
lyrics_id | lyrics_name | lyrics_file
26274	 | Bringin' On the Heartbreak | Bringin-On-The-Heartbreak
47485	 | Bringin On the Heartbreak  | Bringin-On-The-Heartbreak
I should leave one of them, no matter which one.

Thanks in advance!
Add an index on lyrics_file... What does the EXPLAIn of that query tell you anyway?
Reply With Quote
  #3 (permalink)  
Old 12-04-03, 11:22
vanekl vanekl is offline
Registered User
 
Join Date: Nov 2003
Posts: 91
Re: Extremely slow executing of a query

Maybe this will be faster:

select lyrics_id, count(lyrics_file)
from lyrics
group by lyrics_id
having count(lyrics_file) > 1;
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On