Damn, just found out what slowing down my query big time !
Duration for 1 query: 0,141 sec. / 2,012 sec
not having SQL_CALC_FOUND_ROWS versus having it
Any suggestion, workaround ?
There are only like 8000 records in total.
__________________
Found a flower or bug and don't know what it is ? agrozoo.net galery
if you don't spot search button at once, there is search form: agrozoo.net galery search
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,
(select count(t2.term)
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
__________________
Found a flower or bug and don't know what it is ? agrozoo.net galery
if you don't spot search button at once, there is search form: agrozoo.net galery search
Last edited by BubikolRamios; 01-08-2013 at 08:09 AM..
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
as all that does not influence count.
I think it does not do that now.
__________________
Found a flower or bug and don't know what it is ? agrozoo.net galery
if you don't spot search button at once, there is search form: agrozoo.net galery search
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.