Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 9867E2E0032 for ; Mon, 24 Mar 2008 09:39:49 -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 14793-04 for ; Mon, 24 Mar 2008 09:39:46 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mail-in-02.arcor-online.net (mail-in-02.arcor-online.net [151.189.21.42]) by postgresql.org (Postfix) with ESMTP id 9E53A2E003B for ; Mon, 24 Mar 2008 09:39:46 -0300 (ADT) Received: from mail-in-18-z2.arcor-online.net (mail-in-18-z2.arcor-online.net [151.189.8.35]) by mail-in-02.arcor-online.net (Postfix) with ESMTP id 813DE32E7A3; Mon, 24 Mar 2008 13:39:44 +0100 (CET) Received: from mail-in-01.arcor-online.net (mail-in-01.arcor-online.net [151.189.21.41]) by mail-in-18-z2.arcor-online.net (Postfix) with ESMTP id 6BE8B510110; Mon, 24 Mar 2008 13:39:44 +0100 (CET) Received: from [192.168.0.6] (dslb-088-077-045-047.pools.arcor-ip.net [88.77.45.47]) by mail-in-01.arcor-online.net (Postfix) with ESMTP id 3F7AC103FC0; Mon, 24 Mar 2008 13:39:44 +0100 (CET) Message-ID: <47E7A10F.5060805@rp-online.de> Date: Mon, 24 Mar 2008 13:39:43 +0100 From: Thomas Pundt Reply-To: thomas.pundt@rp-online.de User-Agent: Thunderbird 2.0.0.12 (Macintosh/20080213) MIME-Version: 1.0 To: firerox@centrum.cz, pgsql-performance@postgresql.org Subject: Re: slow pg_connect() References: <200803240840.8128@centrum.cz> In-Reply-To: <200803240840.8128@centrum.cz> Content-Type: text/plain; charset=windows-1250; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.92.1/6367/Mon Mar 24 12:19:10 2008 on mail-in-01.arcor-online.net X-Virus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200803/443 X-Sequence-Number: 29397 Hi, firerox@centrum.cz schrieb: > Please, how long takes your connectiong to postgres? > > $starttimer=time()+microtime(); > > $dbconn = pg_connect("host=localhost port=5432 dbname=xxx user=xxx password=xxx") > or die("Couldn't Connect".pg_last_error()); > > $stoptimer = time()+microtime(); > echo "Generated in ".round($stoptimer-$starttimer,4)." s"; > > It takes more then 0.05s :( > > Only this function reduce server speed max to 20request per second. Two hints: * Read about configuring and using persistent database connections (http://www.php.net/manual/en/function.pg-pconnect.php) with PHP * Use a connection pooler such as pgpool-II (http://pgpool.projects.postgresql.org/) Using both techniques together should boost your performance. Ciao, Thomas