>>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
> 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
> USE
>ENDTRY
>
Hi Fabio
>> you can remove ORDER BY because VFP GROUP BY method order the proiection,
and remember m. prefix:
Not realy, Group by without Order by does not make record order ;)