W dniu 2012-09-07 17:43, Aryan Ariel Rodriguez Chalas pisze:
Thank you all for answering that quickly...
A simple query could be "SELECT LOCALTIMESTAMP(0)" which could last even 5 seconds for returning data.
The other queries that I would like to be faster, return less than 50 rows until now; and two of those queries (the ones the application uses the most), return only a record.
I agree that a huge result over internet might take a long time, but until now my application is not returning that amount of rows...
Just for the record, the server bandwidth is 2.0 mbps and the client is 1.89 mbps and other applications run really fast for my expectatives (such as opening a remote desktop and also my application through a remote desktop session runs very fast on this connection). But I'm still far of understanding why over a remote desktop session my application runs very fast on the same connection but when running it locally and connecting to the server, it's super slow. Could be because when running over a remote desktop session the application is connecting with "libpq" through "Unix Domain Socket", but when running locally; "libpq" works over "TCP Sockets"?.
so change connection mode when running the application _at remote_ site _locally_ to the server to
tcp too. And then try with connection to localhost, as well as to the public IP of that server, the
same which you connect to from your own desktop.
By the way I'm using Linux on both ends as Operating System, Lazarus 1.1 as IDE and Zeoslib for connecting to postgresql and I've noticed that when I compile the application for running on Windows as the client, it moves more or less acceptable; so it brings to me to another question: Why "libpq" is faster on Windows than Linux?.
try to benchmark your elementary queries with psql run from your site (remotely to the server) and
from remote site (locally to the server). Use `psql -h hostaddr` at remote site to force tcp connection.
Best regards...
Ariel Rodriguez
----- Mensaje original -----
De: Ireneusz Pluta <ipluta@xxxxx>
Para: Aryan Ariel Rodriguez Chalas <wimogan@xxxxxxxxx>
CC: "pgsql-performance@xxxxxxxxxxxxxx" <pgsql-performance@xxxxxxxxxxxxxx>
Enviado: Viernes, 7 de septiembre, 2012 2:52 A.M.
Asunto: Re: libpq or postgresql performance
W dniu 2012-09-06 22:04, Aryan Ariel Rodriguez Chalas pisze:
-Why if I connect to the remote server desktop (using RDP or any Remote Desktop Application) and run the application using the same internet connection, it runs really fast when making requests to postgresql; but if I run the application locally by connecting to the remote postgresql server through "libpq", it's really slow?.
It might look like the client side fetches too much data or sends too many queries over the connection to the database server and then further processes that data locally. Are you using some kind of ORM in your application?
If that is the case, you might need to refactor your application to do as much as possible computation at server side and deal only with computation results over the connection, not the raw data.
Try to see in server log what SQL statements are executed while you are running your application. You need to SET log_statement TO 'all' for that.
With psql, try to see how much data (how many rows) are returned from that query you call "simple query". Even simple query may return a lot of rows. Server backend might execute it quickly, but returning a huge result over the Internet might take a long time.
--
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance