Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
COPY TO ARRAY against a cursor?
Message
From
05/08/2019 15:56:54
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
05/08/2019 06:40:09
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01669872
Message ID:
01669908
Views:
72
It must have changed in SP2. Using SP1, I don't see a difference using your code (Actually there are differences in a few milliseconds, copy to array being the slowest)

(There is a slight typo in code. First iteration for copy to array would return 1 row 1 column only. Also changed last one to cursor)

>
>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform