select SQL_CALC_FOUND_ROWS g.*,t.id_tezaver_obfuscated,
substring_index(group_concat(t.term order by t.eunis ),',',1) as term,
(select group_concat(distinct tax.source)
from tezaver_taxonomy tax
where tax.id_tezaver = t.id_tezaver
group by tax.id_tezaver ) as taxonomy_src,
from tezaver t2
where t2.id_tezaver = g.id_tezaver and t2.l2 <> 'la') as c
from galery_1 g
left join tezaver t on g.id_tezaver = t.id_tezaver and t.l2 = 'la'
where 1 = 1
group by g.id_galery
order by g.id_galery desc
Anyway, I 'm thinking, not knowing what SQL_CALC_FOUND_ROWS i acualy doing in behind, that it should do following to sql (to get what it gets):
1. remove everything between first SELECT and last FROM, and fill that with only one smat field
2. remove all order by
3. 1 and 2 only in case there is no HAVING
I think all it really does is, first, ignore the LIMIT to get *all* records. And only then in applies the LIMIT to what gets returned. That way, it can count *all* the rows that WOULD be returned. Very primitive but it works. Just not fast.
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.