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 5233ED706A for ; Thu, 29 Sep 2005 17:39:40 -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 56460-03 for ; Thu, 29 Sep 2005 20:39:35 +0000 (GMT) Received: from cluster1.echolabs.net (mail.atlanticbb.net [216.52.118.222]) by svr1.postgresql.org (Postfix) with ESMTP id A5D17D6F5D for ; Thu, 29 Sep 2005 17:39:33 -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 fe1.cluster1.echolabs.net (CommuniGate Pro SMTP 4.3.8) with ESMTPA id 282630; Thu, 29 Sep 2005 16:39:14 -0400 Message-ID: <433C5108.6070202@freedomcircle.net> Date: Thu, 29 Sep 2005 16:39:36 -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: Andreas Pflug Cc: pgsql-performance@postgresql.org Subject: Re: Comparative performance References: <433B4AA4.9080008@freedomcircle.net> <433BDFF3.3090402@freedomcircle.net> <433BEA7B.1050405@pse-consulting.de> In-Reply-To: <433BEA7B.1050405@pse-consulting.de> 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.042 required=5 tests=[AWL=-0.008, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200509/432 X-Sequence-Number: 14740 Andreas Pflug wrote: > Hm, if you only have 4 tables, why do you need 12 queries? > To reduce queries, join them in the query; no need to merge them > physically. If you have only two main tables, I'd bet you only need 1-2 > queries for the whole page. There are more than four tables and the queries are not functionally overlapping. As an example, allow me to refer to the page www.freedomcircle.com/topic.php/Economists. The top row of navigation buttons (Life, Liberty, etc.) is created from a query of the 'topic' table. It could've been hard-coded as a PHP array, but with less flexibility. The alphabetical links are from a SELECT DISTINCT substring from topic. It could've been generated by a PHP for loop (originally implemented that way) but again with less flexibility. The listing of economists is another SELECT from topic. The subheadings (Articles, Books) come from a SELECT of an entry_type table --which currently has 70 rows-- and is read into a PHP array since we don't know what headings will be used in a given page. The detail of the entries comes from that query that I posted earlier, but there are three additional queries that are used for specialized entry types (relationships between topics --e.g., Prof. Williams teaches at George Mason, events, and multi-author or multi-subject articles and books). And there's yet another table for the specific book information. Once the data is retrieved it's sorted internally with PHP, at the heading level, before display. Maybe there is some way to merge all the queries (some already fairly complex) that fetch the data for the entries box but I believe it would be a monstrosity with over 100 lines of SQL. Thanks, Joe