Fast reading?
Thomas Flemming
tf at ttqv.com
Sat Apr 10 08:41:25 CDT 2010
Hi Ivan,
I did some profiling:
> Also consider following way
>
> 1. Use first/next record calls instead of Position property.
makes no difference in time
> 2. Get field pointers out of the loop.
makes the whole story 3x faster!
That's great, thanks guys :-)
Tom
>>>> to write large amount of data into the database there is:
>>>
>>>> "INSERT INTO [mytable] (f1, f2, f3, ... ) VALUES ( :1, :2, :3, ...)"
>>>
>>>> which is very fast.
>>>
>>>> Is there also something similar to READ all fields of a record very fast into
>>>> an array of objects?
>>>
>>>> I'm still doing
>>>
>>>> cursor.Position = i
>>>> f1 = cursor.fields("f1").value
>>>> f2 = cursor.fields("f2").value
>>>> f3 = cursor.fields("f3").value
>>>> ...
>>>
>>>
>>>> which is quiet slow...
>>>
>>> Probably you are trying to solve your needs in an inappropriate way?
>> I hope so ;-)
>
>>>
>>> Say, you get a cursor and fill another table with its data.
>>> So you iterate cursor records getting all column values and do
>>> "inserts" into another table. Instead of doing something like this at
>>> once:
>>>
>>> insert into another_table select f1,f2... from t1...
>>>
>>> Please describe your task and we will find a solution.
>
>> Its not filling another table, I just need them into a .net-object/variable.
>> And so I'm doing
>
>> for i =0 to cursor.recordcount
>> cursor.Position = i
>> f(i).a1 = cursor.fields("f1").value
>> f(i).a2 = cursor.fields("f2").value
>> f(i).a3 = cursor.fields("f3").value
>> next
>
> You did not get the point :)
> What are you doing next? after getting the values?
> Look, probably you do something which might be efficiently solved
> inside some SP rather then extracting data from each record and
> passing it to some algorithm implemented in your .NET code.
>
>
> Also consider following way
>
> 1. Use first/next record calls instead of Position property.
> 2. Get field pointers out of the loop.
>
> Something like
> VField f1 = cursor.fields("f1")
> VField f2 = cursor.fields("f2")
> ...
>
> if( FirstRecord() )
> {
> do
> {
> f(i).a1 = f1.value;
> ...
> } while( NextRecord() )
> }
>
>
>
>
--
/****************************************
** Dipl.-Ing. Thomas Flemming
** Software Development
**
** Touratech AG
** Auf dem Zimmermann 7-9
** D-78078 Niedereschach
**
** mail tf at ttqv.com
** fon +49 (0) 7728 9279-206
** fax +49 (0) 7728 9279-29
**
** http://www.ttqv.com
** http://www.touratech.de
**
** ... und immer dem Pfeil nach!
***************************************/
More information about the Valentina
mailing list