MySQL Forums
Forum List  »  Performance

Query optimize on large database
Posted by: Pavel Volkov
Date: July 13, 2016 01:40AM

Hey guys! I'got table with 300kk rows and ~40 GB size

It got simple structure like [owner_id, Artist, Title] (user's songs list)

My task is simple - need to select the number of matches user's Artist+Title pair (songs) with specified @user_id and display it like [user_id:number_of_matches with specified @user_id]

Got query like that:

SELECT d2.owner_id, COUNT(*) AS kolvo
FROM data d1
JOIN data d2 USING(Artist,Title)
WHERE d1.owner_id = @user_id
GROUP BY d1.owner_id


Got indexes [Artist,Title] and [owner_id]


But the bigger table becomes the more time it takes to execute query...
At first it was pretty fast but now it takes around 1 minute to finish.

Any ideas how to optimize my task? Thanks a lot!

Options: ReplyQuote


Subject
Views
Written By
Posted
Query optimize on large database
1447
July 13, 2016 01:40AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.