sql - Increase MySql EAV query performance -


when run query, took average of 1.2421 seconds, think slow, have added indexing every single possible column in clause. anymore improvement can speed query? table contains data eav have around 111276 rows/records

select sql_calc_found_rows eav.entid,         ent.entname    eav,         ent,         catatt ca   eav.entid = ent.entid         , ent.status = 'active'         , eav.status = 'active'         , eav.attid = ca.attid         , ca.catid = 1         , eav.catid = 1         , ( ca.canviewby <= 6               || ( ent.addedby = 87                    , canviewby <= 6 ) )         , ( ( eav.attid = 13                 , ( `char` = '693fafba093bfa35118995860e340dce' ) )                or ( eav.attid = 3                     , `double` = 6 )                or ( eav.attid = 45                     , ( `int` = 191 ) ) )  group  eav.entid  having count(*) >= 3  

explain output explain output

catatt table index enter image description here

eav table indexenter image description here

ent table index enter image description here

i have simplified query understand better, removed unnecessary case clause, made query planning.

so check query , put comment results , let's debug under answer:

select    sql_calc_found_rows    eav.entid,    ent.entname       eav inner join ent on (eav.entid = ent.entid , ent.status = 'active') inner join catatt on (eav.attid = catatt.attid , catatt.catid = 1)    eav.catid = 1 , eav.status = 'active'    , (catatt.canviewby <= 6 or ent.addedby = 87)    ,   (      (eav.attid = 13 , eav.`char` = '693fafba093bfa35118995860e340dce')      or      (eav.attid = 3 , eav.`double` = 6)      or      (eav.attid = 45 , eav.`int` = 191)    )  group eav.entid having count(eav.entid) > 2  



+ see you've update-ing tables (data inserted these tables) - try make these table's engine myisam
+ create compound indexes combinations of: attid, char ; attid, double ; attid, int
+ take @ mysql's configuration , tune better query caching , memory usage


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -