X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A7C3ED706A for ; Thu, 29 Sep 2005 09:37:01 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 81252-09 for ; Thu, 29 Sep 2005 12:36:56 +0000 (GMT) Received: from cluster1.echolabs.net (smtp-out.echolabs.net [216.52.118.200]) by svr1.postgresql.org (Postfix) with ESMTP id BF2E4D6ECD for ; Thu, 29 Sep 2005 09:36:58 -0300 (ADT) X-Scanned-By: RAE MPP/Clamd http://www.messagepartners.com X-Scanned-By: RAE MPP/Cloudmark http://www.messagepartners.com Received: from [209.187.134.170] (account jma@atlanticbb.net HELO [127.0.0.1]) by fe3.cluster1.echolabs.net (CommuniGate Pro SMTP 4.3.7) with ESMTPA id 1656554; Thu, 29 Sep 2005 08:32:41 -0400 Message-ID: <433BDFF3.3090402@freedomcircle.net> Date: Thu, 29 Sep 2005 08:37:07 -0400 From: Joe Organization: Freedom Circle, LLC User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: PFC Cc: pgsql-performance@postgresql.org Subject: Re: Comparative performance References: <433B4AA4.9080008@freedomcircle.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.018 required=5 tests=[AWL=0.018] X-Spam-Level: X-Archive-Number: 200509/416 X-Sequence-Number: 14724 PFC wrote: > From my experience, the postgres libraries in PHP are a piece of > crap, and add a lot of overhead even from small queries. > For instance, a simple query like "SELECT * FROM table WHERE > primary_key_id=1234" can take the following time, on my laptop, with > data in the filesystem cache of course : > > EXPLAIN ANALYZE <0.1 ms > python + psycopg 2 0.1 ms (damn fast) > php + mysql 0.3 ms > php + postgres 1-2 ms (damn slow) As a Trac user I was considering moving to Python, so it's good to know that, but the rewrite is a longer term project. > So, if your pages are designed in The PHP Way (ie. a large number > of small queries), I might suggest using a language with a decent > postgres interface (python, among others), or rewriting your bunches of > small queries as Stored Procedures or Joins, which will provide large > speedups. Doing >50 queries on a page is always a bad idea, but it's > tolerable in php-mysql, not in php-postgres. The pages do use a number of queries to collect all the data for display but nowhere near 50. I'd say it's probably less than a dozen. As an aside, one of my tasks (before the conversion) was to analyze the queries and see where they could be tweaked for performance, but with MySQL that was never a top priority. The schema is fairly simple having two main tables: topic and entry (sort of like account and transaction in an accounting scenario). There are two additional tables that perhaps could be merged into the entry table (and that would reduce the number of queries) but I do not want to make major changes to the schema (and the app) for the PostgreSQL conversion. Joe