Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with TableUpdate(.F.) being slow
Message
From
12/10/1999 13:30:36
 
 
To
12/10/1999 12:36:58
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00275506
Message ID:
00275526
Views:
19
What is the size of the table? Is it on a server?

Also, the technique you use to generate a new primary key will not work in a multiuser scenario. First, 2 users can have the same SampleId if they hit New at the same time. Second, GO BOTTOM is not Rushmore optimizable and will be slow on big table. Third, you do not check the result of TableUpdate(), so not only the new record will not be saved, but you won't inform the user about it.

A better technique is to use a reference table to get a new primary key. The reference table has only 2 fields: TableName and NextKey. Everytime you need a new PK for a table, you locate the record, lock it, increment the key and return the key.
>I have the following code for adding a record. The Tableupdate takes about six seconds. Everything else the app does is almost instantaneous. Any ideas to speed it up would really be appreciated.
>
>select sample
>saverec = recno()
>go bott
>lastrec = sampleid
>
>append blank
>replace sampleid with lastrec + 1
> messagebox("before") (Put these here to be sure this was slow part)
>tableupdate(.F.)
> messagebox("after")
>
>thisform.cmdEnterTest.enabled = .T.
>thisform.refresh
>
>This is from help and I think it may apply but I don't what to change.
>The table has about 30 fields and 10 small indexes including 1 primary index on sampleid.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform