Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
UDF's second rate citizen in Rushmore ?
Message
From
07/09/2006 09:52:41
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
07/09/2006 08:54:26
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01151219
Message ID:
01151766
Views:
34
Hi Thomas

>Hi Mike,
>>How does VFP update the index when a UDF is involved? Wouldn't that require the UDF to fire? If so, updating records will be faster using the snippet too.
>Ran some tests to identify some of the factors adding to the time needed.
>
>Base table with 5.3*10**7 recs, updating a .dbf field c(35), all tags deleted.
>Reason to update .dbf instead of .cdx: for all runs the disk access writing
>remains the same, which is probably not guaranteed for writing the cdx,
>thereby increasing potential measurement errors
>
>replace all with "" 40 secs, diskbound
>replace all with retFuncEmpty() 50 secs, diskbound
>replace all with retFuncEmpty(cFromMemo) 95 secs, diskbound
>replace all with iif(len(workfunc_snippetlike(cFromMemo)>0, "", "") 406 secs, cpubound
>replace all with workfunc1_03snippetlike(cFromMemo) 403 secs, cpubound
>replace all with workfunc2_09snippetlike(cFromMemo) 403 secs, cpubound
>replace all with workfunc1__12otherFuncs(cFromMemo) 455 secs, cpubound
>
>all functions are in the same procedure file.
>15% is definitely measurable, but not in the same league as adding another
>field, filling it with the current setup and use the existing index again and again.
>
>But I probably will build some primitive logic with compile-constants to
>get me at least part of the 60 seconds in the upper functions called.
>

I think I did not explain myself clearly enough.
CREATE TABLE UDFINDEX (cfield c(10))

LOCAL m.lnX, m.lnA

FOR m.lnX = 1 TO 500000
  INSERT INTO udfindex (cfield) VALUES ("VALUE0")
ENDFOR m.lnX

m.lnA = SECONDS()
REPLACE ALL cField WITH "VALUE1"
?"1 - update - no indexes:",SECONDS()-m.lnA

INDEX on UPPER(cfield) TAG cfield
m.lnA = SECONDS()
REPLACE ALL cField WITH "VALUE1"
?"2 - update regular index:",SECONDS()-m.lnA

INDEX on myudf(cfield) TAG cfield
m.lnA = SECONDS()
REPLACE ALL cField WITH "VALUE1"
?"3 - update UDF index:",SECONDS()-m.lnA
RETURN

PROCEDURE MYUDF
PARAMETERS m.tcField
RETURN UPPER(m.tcField)
I expect #3 to take longest because it should fire UDF every update. It is too slow.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform