Fast reading?

Ivan Smahin ivan_smahin at paradigmasoft.com
Sat Apr 10 07:35:55 CDT 2010


Hello Thomas,

Saturday, April 10, 2010, 12:48:35 PM, you wrote:

> Good Morning,


>>> 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() )
}




-- 
Best regards,
Ivan Smahin 
Senior Software Engineer
Paradigma Software, Inc
Valentina - The Ultra-Fast Database
http://www.valentina-db.com



More information about the Valentina mailing list