IF you "set deleted off", "select count(*) from tstokmast" will take zero time, because VFP understands that this info can be read by the reccount() functions. However, if you have "set deleted on" and no index on deleted(), this will time a looong time. Since you use VFP9, I suggest that you create a binary index on deleted, "index on deleted() tag deleted binary".
Personally I always set deleted off, and I never delete records. In stead I have a logical field which I call "reusable", with a binary index on this field. In stead of deleting, I "replace resusable with .t.". When I need to append records, I first check if I have availabe "reusable" records, and use them before I append new records.
>Set deleted is on
>no index on deleted()
>cpdbf() and cpcurrent() are both 1252.
>already indexed on prodcode field.
>What would be the normal query time for 415k records to run :-
>select count(*) from tstokmast.
>I've got 25 seconds.
>Yau