Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

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, 13:39
Mike Borozdin Mike Borozdin is offline
Registered User
 
Join Date: Sep 2003
Location: St.Petersburg, Russia
Posts: 17
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!
__________________
Mike Borozdin
Reply With Quote
  #2 (permalink)  
Old 12-01-03, 15: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, 12: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

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