Code: Select all
Con:= TUniConnection.Create(nil);
Con.ProviderName := 'PostgreSQL';
Con.Server := '192.168.1.2';
Con.Username := 'zzzz';
Con.Password := 'xxxx';
Con.Database := 'yyyy';
Con.LoginPrompt := False;
Con.Open;
Qry:= TUniQuery.Create(nil);
Qry.Connection := con;
Qry.UniDirectional:= true;
Qry.SQL.Add('select attribute from brazil');
Qry.open;
i:= 0;
while not Qry.eof do
begin
Qry.Next;
i:= i+qry.Fields[0].Asinteger;
end;
Doing the same test with C# and Npgsql.dll, it takes 11 sec. Thats 37x faster.
When I do the same comparison test with SQL Server, C# still takes 11 sec, but UniDAC is only 6.5 sec, which is great.
Any reason it is so slow with UniDAC and postgreSQL ?
The solution to use "select sum(attribute)" is not the answer here. The sum is just for making sure all records are read on the client side.