Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Optimization
Message
From
09/11/2005 16:37:32
 
 
To
09/11/2005 15:27:26
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01066940
Message ID:
01066971
Views:
14
This message has been marked as a message which has helped to the initial question of the thread.
>Ok, I have a sql statement to count all the records that are unique per Doctor which looks similar to this...
>
>select doctor
>do while !eof()
>  llcount = 0
>
>  SELECT count(distinct(UPPER(ALLTRIM(MYTABLE.caddress)))) as llCount
>  FROM MYTABLE WHERE MYTABLE.docid = doctor.docid
>  AND MYTABLE.cstatus <>  "XXX"
>  AND BETWEEN(TTOD(MYTABLE.ddate), tDateFrom, tDateTo)
>  INTO CURSOR curDocTot
>
>  select newtable
>  append blank
>  replace newtable.count with llCount
>
>  skip in doctor
>
>enddo
>
>Currently the MYTABLE contains more than 50K records. I also have an index in MYTABLE.ddate. My problem here is the speed of getting the NEWTABLE being populated, as I see it the bottle neck seems on the SELECT COUNT statment. Is there anything I can do to speed up that SELECT COUNT statment here? Please advice.
>TIA!
 SELECT docid ;
, count(distinct UPPER(ALLTRIM(caddress))) as count ;
  FROM MYTABLE ;
  WHERE cstatus <>  "XXX" ;
  AND ddate BETWEEN m.tDateFrom AND m.tDateTo ;
  GROUP BY 1;
  INTO CURSOR newtable
Previous
Reply
Map
View

Click here to load this message in the networking platform