very slow select statement

D

Dinçer

I have a VB-Access application.
Somewhere in the application, I need to receive data from the database.
I have a select statement that gets the data using 5 tables.
Select statement gets 300 rows of data in almost 25 seconds.
Is it normal (which I think is not)
What can I do to run it faster?


Statement:
SELECT fd.RecId, c.cust_name, fd.Amount, e.sube_adi, a.dst_acc_no,
fd.Explanation
FROM table1 AS f, table2 AS fd, table3 AS c, table4 AS a, table5 AS e
WHERE f.Id = fd.Id
And
fd.CustomerAccId = a.intCustAccId
And
c.CustId = a.CustId
And
e.bank_no like a.bank & '99999'
And fd.Id = 2
ORDER BY c.cust_name;
 
R

Rick Brandt

Dinçer said:
I have a VB-Access application.
Somewhere in the application, I need to receive data from the database.
I have a select statement that gets the data using 5 tables.
Select statement gets 300 rows of data in almost 25 seconds.
Is it normal (which I think is not)
What can I do to run it faster?


Statement:
SELECT fd.RecId, c.cust_name, fd.Amount, e.sube_adi, a.dst_acc_no,
fd.Explanation
FROM table1 AS f, table2 AS fd, table3 AS c, table4 AS a, table5 AS e
WHERE f.Id = fd.Id
And
fd.CustomerAccId = a.intCustAccId
And
c.CustId = a.CustId
And
e.bank_no like a.bank & '99999'
And fd.Id = 2
ORDER BY c.cust_name;

You're using the older syntax of...

Where SomeFieldInTableA = SomeFieldInTableB

You should be using join syntax instead. Other than that you should make
sure that all fields in the joins, ORDER BY, and WHERE clause are indexed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Query multiple table relationships subquery? 1
Merging tables 3
sql query help 1
INNER JOINS in Access 3
rewrite QBE SQL statement 4
Select statement assistance 11
Data Migration 2
Dynaset (Inconsist Upd) 0

Top