General information
Title:
Slow multi-user response
User A adds a new record to a shared table
User B, on a different machine, (or in our test case in another copy of Visual FoxPro running on the same machine) is watching the same table looking for a record with specific content. Fortunately we have an appropriate index. Unfortunately, it is taking from 2 to 5 seconds for user B to find the new record from the time that user A does his replace. What's going on?
User B's code looks something like this
use Food shared in 0
set order to Vegetable
do while .t.
if seek("Turnip")
? "We found it at ", seconds()
exit
endif
enddo
User A tried to speed things up by puting a FLUSH command after the REPLACE, but it didn't help.
Things did speed up though to almost instantaneous response when user B changed his code to:
use Food shared in 0
set order 0 && We won't bother with the index
do while .t.
go top
do while !(Food.Vegetable == "Turnip") and !eof()
skip
enddo
if Food.Vegetable == "Turnip"
? "We found it at ", seconds()
exit
endif
enddo
This brute force method that could end up doing hundreds (or thousands) of skips beats the seek approach hands down. Its as if the table update is seen immediately by both processes, but the index update comes 2 to 5 seconds later. Sure, this is a complicated index, ... but 2 to 5 seconds?
Bob
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only