mysql statement with nested SELECT - how to improve performance
Posted
by ernie
on Stack Overflow
See other posts from Stack Overflow
or by ernie
Published on 2010-04-22T10:53:31Z
Indexed on
2010/04/22
11:43 UTC
Read the original article
Hit count: 289
This statement appears inefficient because only one one out of 10 records are selected and only 1 of 100 entries contain comments.
What can I do to improve it ?
$query = "SELECT
A,B,C,
(SELECT COUNT(*)
FROM comments
WHERE comments.nid = header_file.nid)
as my_comment_count
FROM header_file
Where A = 'admin' "
edit: I want header records even if no comments are found.
© Stack Overflow or respective owner