Thanks for the replies from all of you.
I got around 10% faster by setting DELETED off. By using SYS(3054), I
found that the first SQL-SELECT (takes 35 sec) in the prg is not fully
optimized. I try different ways to SELECT but not success.
Table : SaleList (180,000 records)
Fields: iSaleId, dSaleDate,....
Index : iSaleId, dSaleDate
Table : SaleProd (340,000 records)
Fields: iSaleId, iPdid, iSaleQty,....
Index : iSaleId, iPdid
SELECT SaleProd.iPdid, SUM(SaleProd.iSaleQty) AS TotalSale ;
FROM SaleProd, SaleList ;
WHERE SaleProd.iSaleId = SaleList.iSaleId .AND. ;
SaleList.dSaleDate >= CTOD("14/07/96") ;
GROUP BY SaleProd.iPdid
I got the following message when I run it in command window :
"Optimization level for table SaleProd : none
Use tag dSaleDate for table SaleList
Optimization level for table SaleList : full"
I try next SELECT but have the same result
SELECT SaleProd.iPdid, SUM(SaleProd.iSaleQty) AS TotalSale ;
FROM SaleProd, SaleList ;
WHERE SaleProd.iSaleId IN ;
(SELECT SaleList.iSaleId ;
FROM SaleList ;
WHERE SaleList.dSaleDate >= CTOD("14/07/96")) ;
GROUP BY SaleProd.iPdid
But the third SELECT
SELECT SaleProd.iPdid, SUM(SaleProd.iSaleQty) AS TotalSale ;
FROM SaleProd, ;
WHERE SaleProd.iSaleId >= 170000
I got 90K+ records in 1.7 seconds and the message below :
"Use tag iSaleId for table SaleProd
Optimization level for table SaleProd : full"
I don't know how to improve the optimization level of the first SELECT
statment which is the most time consuming.
Any help would be appreciated.
S H
>
> >I have 6 SQL command in a prg to retrive data into a cursor from 3
> tables(with 9000,180,000 and 340,000 records). When I run the prg from
> project manager, it takes 37 secs. If I run it in the Form.Load(), it
takes
> 60 secs. What is the possible cause?
> >
> >TIA
> >
> >S H
>
> If you have set deleted on then you should definitely have an index on
> DELETED(). It doesn't matter whether or not there are any deleted records,
> VFP still has to check the data. This can make a big difference.
>
> The next thing to do is check for rushmore optimization. If you have VFP 5
> you are in luck with SYS(3054)
> Run SYS(3054, 1) to display optimization. Then run your query from the
> command window to see what optimization is occuring.
>
> Make sure you have appropriate indexes that match each of the conditions
of
> the join. I would not be happy if queries on three tables took any longer
> that 5 seconds. It sounds to me like there is plenty of room for
> optimization. SYS(3054) can be very useful as you modify your view join
> condition and indexes.
>
> Bob
>
>
Siu-hung Lai