Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
COPY TO ARRAY against a cursor?
Message
From
05/08/2019 06:40:09
 
 
To
02/08/2019 16:59:14
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., New Zealand
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01669872
Message ID:
01669903
Views:
77
>JR>>The other option is SELECT into ARRAY, but Tamar's paper calls that an order of magnitude slower for a small resultset...
>>>I don't think I've ever tested COPY TO ARRAY vs. SELECT INTO ARRAY. The paper I think you're referring was addressing using SEEK to find a single record vs. using SQL SELECT.
>
>Foxteach 2001 paper "You need arrays" : "Although SQL SELECT can do everything that COPY TO ARRAY can, COPY TO ARRAY is as much as an order of magnitude faster with small data sets."
>
>Sheesh, if I can forget the ARRAY in COPY TO ARRAY, I guess you're allowed not to remember every sentence of the hundreds of thousands- millions even? - that you have published over decades! ;-) - J

Wow, I had no memory of that. But I'm a pack rat, so I just dug up the test code and in VFP 9 SP2 with all hotfixes, I'm seeing about half an order of magnitude difference. Here's the test code (and yes, I might write it differently today than I did in 2001):
* Compare SELECT INTO ARRAY to COPY TO ARRAY
#DEFINE PASSES 10000

LOCAL aUKEmps[1], aMsgs[1], nPass, nStart, nEnd

* pre-open table
USE _SAMPLES+"TasTrade\Data\Employee"

* Test 1: COPY TO ARRAY

nStart = SECONDS()

FOR nPass = 1 TO PASSES
	COPY TO ARRAY aUKEmps ;
	   FIELDS First_Name, Last_Name, Birth_Date ;
	   FOR Country = "UK"
	RELEASE aUKEmps
ENDFOR

nEnd = SECONDS()

? "Using COPY TO ARRAY, ", PASSES, " passes took ", nEnd-nStart, "; records in result = ", _TALLY

* Test 2: SQL SELECT

nStart = SECONDS()

FOR nPass = 1 TO PASSES
	SELECT first_name, last_name, birth_date ;
	   FROM Employee ;
	   WHERE Country = "UK" ;
	   INTO ARRAY aUKEmps
	RELEASE aUKEmps
ENDFOR

nEnd = SECONDS()

? "Using SQL SELECT, ", PASSES, " passes took ", nEnd-nStart

* Test 3: SQL SELECT to cursor

nStart = SECONDS()

FOR nPass = 1 TO PASSES
	SELECT first_name, last_name, birth_date ;
	   FROM Employee ;
	   WHERE Country = "UK" ;
	   INTO ARRAY aUKEmps
	RELEASE aUKEmps
ENDFOR

nEnd = SECONDS()

? "Using SQL SELECT to cursor, ", PASSES, " passes took ", nEnd-nStart
Tamar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform