Re: Speeding up guerys
Posted in 1998
Trond-Eirik Kolloen wrote:
> Hello
>
> I'm developing a MFC app connecting to a informix database by using ODBC.
> I'm really fresh in this, so any help will be gladly recived.
> This application is using 5 different SQL querys over and over again, but
> with different parameters.
>
> This is function very good, excep when I'm getting to the last guery.
>
> The querys are like this: (the values of the ? will depend on the previus
> query
>
> select * from language
> select * from lang_dep_rep where lang_name = ?
> select * from lang_dep_pg where lang_name = ? and rep_num = ?
> select * from lang_dep_vg where lang_name = ? and rep_num = ? and pg_num = ?> select* from lang_dep_rub where lang_name = ? and rep_num = ? and pg_num = ?
> and vg_num = ?
>
> Every one of this querys will never return mutch more than 20 records.
>
Hi
What about joins? They will work faster. I didn't try this, but it should be
something like:
select * from language l, lang_dep_rep r, lang_dep_pg p, lang_dep_vg v,lang_dep_rub u
where l.lang_name = r.lang_name
and p.lang_name = r.lang_name and p.rep_num = r.rep_num
and v.lang_name = p.lang_name and v.rep_num = r.rep_num and v.pg_num =
r.pg_num
and u.lang_name = v.lang_name and u.rep_num = v.ret_num and u.pg_num =
v.pg_num
and u.vg_num = v.vg_num
Even better if you specify the columns, you really need. Instead fo "select *
from ..." you should say "select v.pg_name, u.pg_name from ...". I know it is
convenient to say "select *", but it is worth the trouble specifying columns.
If Informix-Databas have enough information in his index, he do not even read
the data-pages.
Tommi M'kitalo
Dr. Eckhardt + Partner GmbH