Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TbU7o-0000wH-9I for pgsql-performance@postgresql.org; Thu, 22 Nov 2012 10:35:16 +0000 Received: from outmail148094.authsmtp.co.uk ([62.13.148.94]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TbU7g-0006Oy-Uh for pgsql-performance@postgresql.org; Thu, 22 Nov 2012 10:35:15 +0000 Received: from mail-c226.authsmtp.com (mail-c226.authsmtp.com [62.13.128.226]) by punt7.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id qAMAZ7HN071201; Thu, 22 Nov 2012 10:35:07 GMT Received: from ayaki.localdomain (124-148-90-153.dyn.iinet.net.au [124.148.90.153]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/) with ESMTP id qAMAYuqi013091 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Thu, 22 Nov 2012 10:35:00 GMT Message-ID: <50ADFFD0.7070503@2ndQuadrant.com> Date: Thu, 22 Nov 2012 18:34:56 +0800 From: Craig Ringer Organization: 2nd Quadrant User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121029 Thunderbird/16.0.2 MIME-Version: 1.0 To: Sergio Mayoral CC: postgresql-perf Subject: Re: PQconnectStart/PQconnectPoll References: <1352970177.10135.YahooMailNeo@web39302.mail.mud.yahoo.com> In-Reply-To: <1352970177.10135.YahooMailNeo@web39302.mail.mud.yahoo.com> X-Enigmail-Version: 1.4.5 Content-Type: multipart/alternative; boundary="------------070106050009030902090102" X-Server-Quench: 44f49523-3490-11e2-98a9-0025907ec6c5 X-AuthReport-Spam: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-AuthRoute: OCdxZQATClZeVg0b BQteCiN5VAwpPBRK HVkIKg5MJUcNSQVJ NksadBtFagdbY1ZH HGQLWlZEUV17WmZ/ awsfbAdZfEtKVxtj UFZIR1FNFgBqBAMA SF9vL2gbMkQfeH9z ZU9jEHFZX0Z9O0J5 FEpdEG8FeGRkYWAC UUENdR5deFJDYx9F aFV2VHRYMmNUYzQC El17DAgcBxt4EgFg Cjk0JlUUR0sAAgUg TgoeWg0WFkoDQSg4 MyQhLlp0 X-Authentic-SMTP: 61633235383639.1020:706 X-AuthFastPath: 0 (Was 255) X-AuthSMTP-Origin: 124.148.90.153/2525 X-AuthVirus-Status: No virus detected - but ensure you scan with your own anti-virus system. X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201211/253 X-Sequence-Number: 48619 This is a multi-part message in MIME format. --------------070106050009030902090102 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On 11/15/2012 05:02 PM, Sergio Mayoral wrote: > > PQconnectdb is taking too long comparing to mysql and i found out the > time is consumed by PQconnectPoll waiting for the socket to be ready > for reading/writing What's "too long"? > > I cannot use persistent connections. I must open/close a connection > anytime I want to insert something new. If you mean that you intend to open a new connection, do a single INSERT, and close the connection - your performance will be awful. If your app can't use persistent or pooled connections, use PgBouncer as an external connection pool. Have your app connect to PgBouncer, and PgBouncer connect to PostgreSQL. -- Craig Ringer http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services --------------070106050009030902090102 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
On 11/15/2012 05:02 PM, Sergio Mayoral wrote:

PQconnectdb is taking too long comparing to mysql and i found out the time is consumed by PQconnectPoll waiting for the socket to be ready for reading/writing
What's "too long"?

I cannot use persistent connections. I must open/close a connection anytime I want to insert something new.
If you mean that you intend to open a new connection, do a single INSERT, and close the connection - your performance will be awful.

If your app can't use persistent or pooled connections, use PgBouncer as an external connection pool. Have your app connect to PgBouncer, and PgBouncer connect to PostgreSQL.


-- 
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services
--------------070106050009030902090102--