望高手解決數據庫查詢問題!
select acct02a.cust_id,acct02a.custname,acct15a.ar_tran,acct15a.tran_d,acct16b.ar_vouch,acct16b.vouch_d,acct16b.payamnt,acct15a.ttlamnt from acct02a,acct15a,acct16b where (acct15a.tran_d>=40909 and acct15a.tran_d<=40939) and (acct02a.cust_id=acct15a.cust_id) and (acct16b.ar_tran=acct15a.ar_tran) AND (acct02a.cust_id>='AH001' and acct02a.cust_id<='ZM203') order by acct02A.CUST_ID
例如以上語句,在SQL 查詢器中執行顯示時間為0.02秒.但是利用DELPHI的ADOQUERY控制提取所有記錄(結果大概5000千記錄),需要時間3分鍾左右.請問在DELPH如果可以將上面SQL查詢的結果快速提取出來? delphi
[解决办法]
将SQL改成下面的试试:
select acct02a.cust_id,acct02a.custname,acct15a.ar_tran,acct15a.tran_d,acct16b.ar_vouch,acct16b.vouch_d,acct16b.payamnt,acct15a.ttlamnt
from acct02a join acct15a on (acct02a.cust_id=acct15a.cust_id) and (acct02a.cust_id>='AH001' and acct02a.cust_id<='ZM203') and (acct15a.tran_d>=40909 and acct15a.tran_d<=40939)
join acct16b (acct16b.ar_tran=acct15a.ar_tran)
order by acct02A.CUST_ID
[解决办法]
select acct02a.cust_id,acct02a.custname,acct15a.ar_tran,acct15a.tran_d,acct16b.ar_vouch,acct16b.vouch_d,acct16b.payamnt,acct15a.ttlamnt from acct02a,acct15a,acct16b where (acct15a.tran_d>=40909 and acct15a.tran_d<=40939) and (acct02a.cust_id=acct15a.cust_id) and (acct16b.ar_tran=acct15a.ar_tran) AND (acct02a.cust_id>='AH001' and acct02a.cust_id<='ZM203') order by acct02A.CUST_ID