Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 1E9352E0032 for ; Mon, 24 Mar 2008 05:04:36 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 26172-04 for ; Mon, 24 Mar 2008 05:04:33 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from www.postnewspapers.com.au (www.postnewspapers.com.au [202.61.230.242]) by postgresql.org (Postfix) with ESMTP id 7DD8D2E002D for ; Mon, 24 Mar 2008 05:04:33 -0300 (ADT) Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by www.postnewspapers.com.au (Postfix) with ESMTP id 5A34FD5576; Mon, 24 Mar 2008 17:04:29 +0900 (WST) Received: from localhost (access [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 713F41E0435; Mon, 24 Mar 2008 17:04:30 +0900 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (access.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 5ToXBWbeOtVe; Mon, 24 Mar 2008 17:04:28 +0900 (WST) Received: from [203.161.97.213] (203.161.97.213.static.amnet.net.au [203.161.97.213]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTP id D89231E0434; Mon, 24 Mar 2008 17:04:27 +0900 (WST) Message-ID: <47E76087.3050901@postnewspapers.com.au> Date: Mon, 24 Mar 2008 17:04:23 +0900 From: Craig Ringer User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 To: firerox@centrum.cz Cc: pgsql-performance@postgresql.org Subject: Re: slow pg_connect() References: <200803240840.8128@centrum.cz> <47E75F18.9060206@postnewspapers.com.au> In-Reply-To: <47E75F18.9060206@postnewspapers.com.au> X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=windows-1250; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200803/438 X-Sequence-Number: 29392 Craig Ringer wrote: > firerox@centrum.cz wrote: >> It takes more then 0.05s :( >> >> Only this function reduce server speed max to 20request per second. >> > If you need that sort of frequent database access, you might want to > look into: > > - Doing more work in each connection and reducing the number of > connections required; > - Using multiple connections in parallel; > - Pooling connections so you don't need to create a new one for every > job; > - Using a more efficient database connector and/or language; > - Dispatching requests to a persistent database access provider that's > always connected > Oh, I missed: Use a UNIX domain socket rather than a TCP/IP local socket. Database interfaces that support UNIX sockets (like psycopg) will normally do this if you omit the host argument entirely. -- Craig Ringer