Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Optimizing the complex query
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Optimizing the complex query
Miscellaneous
Thread ID:
00592136
Message ID:
00592136
Views:
68
Hi everybody,

Here is a query, which I want to optimize:
SELECT count(.T.) AS GBCount, ;
       sitemstr.ccode  AS ccodegrp  ;
       FROM propmstr ;
       inner JOIN sitemstr on propmstr.propid = sitemstr.propid ;
       left JOIN bldgmstr on propmstr.propid = bldgmstr.propid ;
       where  Prefcode = "P" and INLIST(SiteMstr.ccode,"10","01") ;
       and ZIPCODE<>"     " and (StNum>0 or (LotCode="C" and Unit<>"      ")) ;
       and LIKE("*=*",OWNER1) and inlist(PropMstr.SellName,"P","Y") ;
       and BETWEEN(LstMtgDate,{^1998-12-01},{^2000-12-30}) and ;
       BETWEEN(LstMtg,200000,500000) and InactvFl#"A" ;
       GROUP BY ccodegrp  INTO TABLE ..\..\work\query\qryR0KWT4F
I excluded two joins from this query, which makes it even more complicated.

PropMstr has indexes on PropID, LstMtgDate, LstMtg. Deleted
SiteMstr has indexes on PrefCode, and ZipCode. Deleted

This query takes 153 sec. to run with set deleted on (this setting should be used).

SiteMstr is ~ 4mln. recs, PropMstr is ~ 3.5 mln. recs

What would be your suggestions? Addint indexes on StNum, LotCode, Unit in SiteMstr? SellName is 1 ch. field in PropMstr, do we need to have index on it?
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform