Email: View mit Index

Beitrag lesen

Ich hab da einen ziemlich komplexen Join mit mehreren WHERE Klausen. Das eine verklauselte Feld ist jedoch in der Tabelle nicht indiziert. Das könnte bei vielen Einträgen in der Tabelle zu Performanceproblemen führen, dem möchte ich vorbeugen Idee:

Ich erstelle ein View und lege in diesem View einen Index auf das besagte Feld. Frage vorab: Sorgt MySQL dann selbst dafür daß das View einschließlich Index aktuell ist? Etwa wenn die Basistabelle neue Einträge bekommt?

MFG

explain
                SELECT
                    a.ent as entity,
                    b.val as datetime,
                    c.val as nickname,
                    d.val as body,
                    e.val as parent,
                    f.val as root,
                    g.val as subject,
                    h.val as thread,
                    i.val as timestamp,
                    j.val as threadroot
                FROM forum a
                JOIN forum b using(ent,att)
                JOIN forum c using(ent)
                JOIN forum d using(ent)
                JOIN forum e using(ent)
                JOIN forum f using(ent)
                JOIN forum g using(ent)
                JOIN forum h using(ent)
                JOIN forum i using(ent)
                JOIN forum j using(ent)
                WHERE b.att = 'datetime'
                AND c.att = 'nickname'
                AND d.att = 'body'
                AND e.att = 'parent'
                AND f.att = 'root'
                AND g.att = 'subject'
                AND h.att = 'thread'
                AND i.att = 'timestamp'
                AND j.att = 'threadroot'
                and h.val = 91761

"id","select_type","table","type","possible_keys","key","key_len","ref","rows","Extra"
1,"SIMPLE","g","ref","PRIMARY,ent,att","att","130","const",38,"Using where"
1,"SIMPLE","d","eq_ref","PRIMARY,ent,att","PRIMARY","260","myweb.g.ent,const",1,"Using where"
1,"SIMPLE","e","eq_ref","PRIMARY,ent,att","PRIMARY","260","myweb.g.ent,const",1,"Using where"
1,"SIMPLE","h","eq_ref","PRIMARY,ent,att","PRIMARY","260","myweb.g.ent,const",1,"Using where"
1,"SIMPLE","j","eq_ref","PRIMARY,ent,att","PRIMARY","260","myweb.h.ent,const",1,"Using where"
1,"SIMPLE","a","eq_ref","PRIMARY,ent,att","PRIMARY","260","myweb.d.ent,const",1,"Using where; Using index"
1,"SIMPLE","b","eq_ref","PRIMARY,ent,att","PRIMARY","260","myweb.j.ent,const",1,"Using where"
1,"SIMPLE","c","eq_ref","PRIMARY,ent,att","PRIMARY","260","myweb.a.ent,const",1,"Using where"
1,"SIMPLE","f","eq_ref","PRIMARY,ent,att","PRIMARY","260","myweb.j.ent,const",1,"Using where"
1,"SIMPLE","i","eq_ref","PRIMARY,ent,att","PRIMARY","260","myweb.j.ent,const",1,"Using where"

sieht eigentlich gut aus, kein Fullscan, nur 38 rows. Lohnt ich das view?