Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
LOCATE goes out to lunch when working in buffer
Message
From
02/02/2000 00:54:31
 
 
To
01/02/2000 23:55:20
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00325976
Message ID:
00325990
Views:
28
>OK, here's the sitch. A parent table OWNERS has two child PERSON records. I allow the user to delete the second PERSON record in a child form. Both tables have optimistic table buffering. Things work pretty well if I just delete the record and save. The save routine wraps a transaction around the table updates. The save after the delete takes less than a second to complete.
>
>The refreshed display is a little funky, though, so I reason that I should move back to the non-deleted PERSON record after deleting and before saving:
>
>LOCATE FOR PERSON.iOWNERS == OWNERS.iOWNERS and PERSON.nOrder == 1
>
>This instruction takes 30 SECONDS to execute!

Is the record adjacent? If so, this is klugy, but try:
IF ! BOF()
   SKIP -1
ENDIF
IF (BOF() OR Person.iOwners # Owners.iOwners) AND ! EOF()
   SKIP
ENDIF

Another possibility is that the LOCATE must search without Rushmore, from the top in index order. Try:

LOCAL cIndexOrder
cIndexOrder = TAG()
SET ORDER TO
LOCATE FOR PERSON.iOWNERS == OWNERS.iOWNERS and PERSON.nOrder == 1
IF ! EMPTY(cIndexOrder )
   SET ORDER TO (cIndexOrder)
   SKIP 0
ENDIF
Other xBASE-y things like reliance on SET RELATION, SET FILTER, etc. can make life difficult for you and force VFP to work record-by-record

>
>Note that there are 171,637 records in the PERSON table and there is an index on PERSON.iOWNERS. There is no index on PERSON.nOrder.
>

Using an update-able parameterized view for the child table, deleting in the view and then applying the update (if you also buffer the base table, it needs to be TABLEUPDATEd as well) should not have this problem. I try to avoid working against base tables if at all possible, if for no other reason than to limit the amount of damage I can do. And as usual, using views makes the change to a client/server environment and philosophy easier in the long run.

>
>Summary:
> 30 seconds with buffered records and an indexed field
> 3 seconds with unbuffered records and no index
> 30 milliseconds with unbuffered records and an indexed field
>
>I will also try to recreate the buffered situation from a small program run from the command box. But I thought I would ask if anyone has seen this behavior.
>

My guess is that one of the two methods above will help.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform