Re: Long execution time despite LIMIT 3
Posted by:
Joachim Berger ()
Date: June 21, 2011 02:06AM
It somehow seems I might be getting there:
I could rewrite the SELECT as follows:
(SELECT m.*, m.flags + 0 flags
FROM messages_test m
WHERE (m.thread = 817549.001266066) AND (id_user_s = 817549) AND (del_s = 0))
UNION
(SELECT m.*, m.flags + 0 flags
FROM messages_test m
WHERE (m.thread = 817549.001266066) AND (id_user_r = 817549) AND (del_r = 0))
order by id desc
LIMIT 3;
and have indexes like:
test1 (thread,id_user_r,del_r)
test2 (thread,id_user_s,del_s)
What do you think?