Subject | how to optimize this query ? |
---|---|
Author | nathanelrick |
Post date | 2012-02-20T10:22:23Z |
Hello,
this is my query :
Select
MAINTABLE.ID
from
MAINTABLE
Join SECONDTABLE on SECONDTABLE.ID_obj=MAINTABLE.ID_obj
Join THIRDTABLE on THIRDTABLE.ID_obj=MAINTABLE.ID_obj
where
(MAINTABLE.name = 'jean' or
SECONDTABLE.name = 'jean' or
THIRDTABLE.name = 'jean')
I have an index on
MAINTABLE.name
SECONDTABLE.name
THIRDTABLE.name
the probleme is that firebird use
PLAN JOIN (THIRDTABLE NATURAL, SECONDTABLE INDEX (RDB$PRIMARY436), MAINTABLE INDEX (RDB$PRIMARY26))
and it not use the index of the field
MAINTABLE.name
SECONDTABLE.name
THIRDTABLE.name
:(
this is my query :
Select
MAINTABLE.ID
from
MAINTABLE
Join SECONDTABLE on SECONDTABLE.ID_obj=MAINTABLE.ID_obj
Join THIRDTABLE on THIRDTABLE.ID_obj=MAINTABLE.ID_obj
where
(MAINTABLE.name = 'jean' or
SECONDTABLE.name = 'jean' or
THIRDTABLE.name = 'jean')
I have an index on
MAINTABLE.name
SECONDTABLE.name
THIRDTABLE.name
the probleme is that firebird use
PLAN JOIN (THIRDTABLE NATURAL, SECONDTABLE INDEX (RDB$PRIMARY436), MAINTABLE INDEX (RDB$PRIMARY26))
and it not use the index of the field
MAINTABLE.name
SECONDTABLE.name
THIRDTABLE.name
:(