Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select Count(*) performance
Message
From
05/08/2006 02:47:16
 
 
To
04/08/2006 17:35:11
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 8
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01143102
Message ID:
01143166
Views:
9
This message has been marked as a message which has helped to the initial question of the thread.
>Hello.
>I have a table with 200 000 records. (not much i think)
>I do next SQL Select to display how many products in each group
>
> Select group, Count(*) As _count;
> FROM table;
> Where table.manufactureID = manufactureID;
> GROUP By group;
> ORDER By group;
> Into Cursor _curgroup
>
>As result I have 420 records.. but my SQL time nearly 3 seconds.
>I have index by ManufactureID and by Group for Rushmore optimization.
>I have very fast computer with 1Gb RAM.
>
>Is it normal performace? May I get performance better? Because when i navigate in form from one Manufacture to another.. I have 3 sec delay.. and it looks not good ;(
>
>Thanks
>Denis

VFP is not able to optimize GROUP BY and/or ORDER BY.

you can remove ORDER BY because VFP GROUP BY method order the proiection,
and remember m. prefix:
Select group, Count(*) As _count;
FROM table;
Where table.manufactureID = m.manufactureID;
GROUP By group;
Into Cursor _curgroup
Or writes a XBase program
Select group, Count(*) As _count;
FROM table;
Where .F.;
GROUP By group;
Into Cursor _curgroup READWRITE

* optimized grouping
TRY
 SELECT 0
 USE DBF("table") AGAIL ALIAS _table ORDER manufactureID_group && A COMPOSED INDEX, like BINTOC(m.manufactureID)+Group
 SET EXACT OFF
 IF SEEK(BINTOC(m.manufactureID))
   SCAN WHILE manufactureID = m.manufactureID
        INSERT INTO _curgroup VALUES (_table.group,0)
        COUNT WHILE group = _curgroup.group AND manufactureID = m.manufactureID TO _count
        REPLACE IN _curgroup _count WITH m._count
   ENDSCAN
 ENDIF
FINALLY
 SET EXACT ON && restore SET EXACT
 USE
ENDTRY 
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform