Not the answer you need?
Register and ask your own question!

Speeding up sort with subquery?

Alexandr KrilofAlexandr Krilof EntrantInactive User Role Beginner
Hello. I have percona server 5.7 and SQL query something like:
SELECT
(SELECT count(*) FROM table2 WHERE id=t1.t2_id) as query1,
(SELECT count(*) FROM table3 WHERE id=t1.t3_id) as query2
FROM
table1 t1
ORDER BY
query1 desc, query2 desc, t1.id desc

With order by I have execute time: 54sec, without order by I have execute time 0.3sec.
Can I speed up the execution of the query?
Thanks.

Comments

Sign In or Register to comment.

MySQL, InnoDB, MariaDB and MongoDB are trademarks of their respective owners.
Copyright ©2005 - 2020 Percona LLC. All rights reserved.