MySQL Forums :: Performance :: Query optimize on large database


Advanced Search

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 540 Pavel Volkov 07/13/2016 01:40AM
Re: Query optimize on large database 317 Rick James 07/15/2016 05:12PM
Re: Query optimize on large database 321 Pavel Volkov 07/16/2016 04:15AM
Re: Query optimize on large database 308 Peter Brawley 07/16/2016 12:09PM
Re: Query optimize on large database 297 Pavel Volkov 07/16/2016 12:36PM
Re: Query optimize on large database 289 Rick James 07/16/2016 02:46PM
Re: Query optimize on large database 302 Peter Brawley 07/17/2016 11:22AM
Re: Query optimize on large database 290 Pavel Volkov 07/18/2016 04:28AM
Re: Query optimize on large database 275 Peter Brawley 07/18/2016 08:40AM
Re: Query optimize on large database 296 james wang 07/20/2016 04:46AM
Re: Query optimize on large database 277 Pavel Volkov 07/20/2016 08:06AM
Re: Query optimize on large database 292 Rick James 07/20/2016 09:29AM
Re: Query optimize on large database 289 james wang 07/21/2016 04:35AM


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.