performance concern

25 views
Skip to first unread message

c...@cyf.com.ar

unread,
Apr 5, 2015, 11:24:44 AM4/5/15
to npgsq...@googlegroups.com
hello everybody and thanks in advance for your support,
I'm using the npgsql library in the following process:

Dim connRemote As New NpgsqlConnection("my data connection string")
connRemote.Open()
If connRemote.FullState = ConnectionState.Open Then
' first query
Dim command1 As New NpgsqlCommand("select product_id from products order by product_id asc limit 1", connRemote)
Dim DR1 As Npgsql.NpgsqlDataReader
DR1 = command.ExecuteReader()
While DR1.Read()
If CInt(DR1.GetValue(DR.GetOrdinal("product_id")).ToString) > 0 Then
'do something minor here
End If
End While
DR1.Close()
' second query
Dim command2 As New NpgsqlCommand("select order_id from orders order by order_id asc limit 1", connRemote)
Dim DR2 As Npgsql.NpgsqlDataReader
DR2 = command.ExecuteReader()
While DR2.Read()
If CInt(DR2.GetValue(DR.GetOrdinal("product_id")).ToString) > 0 Then
'do something minor here
End If
End While
DR2.Close()
'...........
' the process repeats 20 times with different simple querys
end if

the problem is the whole process is taking aprox. 5 seconds to complete.
5 seconds seems much time to me, if i execute the querys individually trough pgadmin each one takes less than 20 milliseconds.
do am I making something wrong..?
ps1: the server use SSL for connection method.
ps2: postgres server 8.4 running on CentOS 5.7
Reply all
Reply to author
Forward
0 new messages