Subject RE: [firebird-support] Speed issues
Author Leyne, Sean
Zoran,

> Query
> ------------------------------------------------
> select distinct
> articles.art_id,
> articles.art_article_nr,
> generic_articles.ga_id,
> link_art.la_id,
> link_la_typ.lat_sort sort,
> link_la_typ.lat_sup_id bra_id,
> articles.art_replacement
> from link_la_typ
> inner join generic_articles on lat_ga_id = ga_id
> inner join link_art on lat_la_id = la_id
> inner join articles on la_art_id = art_id
> where lat_typ_id=:TYP_ID  and ga_id=:GA_ID
> ORDER BY 7 ASC
>        , 2 ASC
>
> Plan
> ------------------------------------------------
> PLAN SORT (SORT (JOIN (LINK_LA_TYP INDEX (LINK_LA_TYP_IDX1,
> LINK_LA_TYP_IDX3), GENERIC_ARTICLES INDEX (GENERIC_ARTICLES_IDX1),
> LINK_ART INDEX (LINK_ART_IDX1), ARTICLES INDEX (ARTICLES_IDX1))))

The plan is showing, "(LINK_LA_TYP_IDX1, LINK_LA_TYP_IDX3)", that if you created a compound index with the lat_typ_id and lat_ga_id (the field with the most common values first) would allow the engine to apply more 'selective' use of the indexes.


Sean