Speeding up guerys
Posted in 1998
Topics: SQL Development & Query Writing, Stored Procedures & SPL, Connectivity: ODBC / JDBC / .NET
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.
The tables look like this:
language: Table (2 records)
lang_name: char(20) :PK
lang_dep_rep: Table (15 records)
rep_num: char(20): PK
lang_name: char(20): PK, FK
rep_name: char(255)
lang_dep_pg: Table
pg_num: char(20): PK
rep_num: char(20): PK, FK
lang_name: char(20): PK, FK
pg_name: char(255)
lang_dep_vg: Table
vg_num: char(20): PK
pg_num: char(20): PK, FK
rep_num: char(20): PK, FK
lang_name: char(20): PK, FK
pg_name: char(255)
land_dep_rub: Table (40.000 records)
rub_num: char(20)_ PK
vg_num: char(20): PK, FK
pg_num: char(20): PK, FK
rep_num: char(20): PK, FK
lang_name: char(20): PK, FK
pg_name: char(255)
So my question is, how may I speed up this querys. Spesially the last one
(on lang_dep_rub)? I wont it to go really FAST.
Now it takes about 2 seconds to do the guery on lang_dep_rub.
The time consume is at the database, because it is very clear that it takes
more time the futher down in the hierarcy you get.
I would be glad for any ideas. (what about stored procedures?)
Please send a CC by email: tek.epas@elanders.no
Regards
Trond-Eirik Kolloen