mysql query slow

i'm running a query that takes over 6sec to finish. The table has +50000 records, but i would like to speed it up. I have already added some indexes.
Any additional help?

SELECT `User`.`id`, `Profile`.`diagnose_details`, `Profile`.`phone`, `Profile`.`cellphone`, `Profile`.`city`, `Profile`.`zip`, `Profile`.`comments`, `Profile`.`recalls`, (DATE_FORMAT(`User`.`registered`, "%d/%m/%Y")) AS `User__registration_date`, (CONCAT(`Profile`.`first_name`, " ", `Profile`.`last_name`)) AS `User__fullname`, (DATE_FORMAT(`Profile`.`recall_date`, "%d/%m/%Y %H:%i")) AS `User__recall_at`, (CASE WHEN DAYOFWEEK(`User`.`registered`) IN (1, 2, 3, 4) THEN `User`.`registered` + INTERVAL 0 DAY < NOW() WHEN DAYOFWEEK(`User`.`registered`) IN (5, 6) THEN `User`.`registered` + INTERVAL 2 DAY < NOW() WHEN DAYOFWEEK(`User`.`registered`) = 7 THEN `User`.`registered` + INTERVAL 1 DAY < NOW() END) AS `User__showbutton`, (NOW() < `Lock`.`expired`) AS `User__is_locked` FROM `andulbe_live_nl`.`users` AS `User` LEFT JOIN `andulbe_live_nl`.`profiles` AS `Profile` ON (`Profile`.`user_id` = `User`.`id`) LEFT JOIN `andulbe_live_nl`.`visit_calendars` AS `Followup` ON (`User`.`id` = `Followup`.`visitor_id` AND `Followup`.`is_followup` = 1) LEFT JOIN `andulbe_live_nl`.`locks` AS `Lock` ON (`User`.`id` = `Lock`.`foreign_key` AND `Lock`.`task` = 'callcenter_booking') WHERE `User`.`group_id` = 3 AND `User`.`app` IS NULL GROUP BY `User`.`id` ORDER BY `User`.`registered` desc LIMIT 20
ads711Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
can you please show the EXPLAIN plan for the query?
http://dev.mysql.com/doc/refman/5.0/en/explain.html
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
and of course check the mysql server parameters, and peform the "usual" tuning, if not yet done:
http://dev.mysql.com/doc/refman/5.0/en/server-parameters.html
usually, the memory size assigned to mysql is by default small, which makes it often go "bad" when the database grows larger than the default small config
0
ads711Author Commented:
explain sql
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

Tomas Helgi JohannssonCommented:
Hi!

Make sure that all your tables that are involved in the query has indexes that match the columns of the join and where clause

Put this index if you don't have it on your User table
( id asc, group_id asc, app asc, registered asc)

Regards,
    Tomas Helgi
0
ads711Author Commented:
ok, how can i add it using a query?
0
Tomas Helgi JohannssonCommented:
Hi!

You need to execute this create index statement.

CREATE INDEX user_id_group_ix1 on USER ( id asc, group_id asc, app asc, registered asc);
 
http://dev.mysql.com/doc/refman/5.5/en/create-index.html

This index will elminate line 2 and 3 of your explain and add a new line for this index instead.

Regards,
    Tomas Helgi
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.