X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0EDA152861 for ; Fri, 3 Jun 2005 09:22:50 -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 42006-01 for ; Fri, 3 Jun 2005 12:22:47 +0000 (GMT) Received: from mail3.vodafone.ie (lughnasa.vodafone.ie [213.233.128.5]) by svr1.postgresql.org (Postfix) with ESMTP id 17F8E52802 for ; Fri, 3 Jun 2005 09:22:45 -0300 (ADT) Received: from iecsai19 (10.163.136.100) by mail3.vodafone.ie (7.2.033.1) id 428A1D1200068C74; Fri, 3 Jun 2005 13:22:42 +0100 Message-ID: <189960.1117801361979.JavaMail.tomcat@iecsai19> Date: Fri, 3 Jun 2005 13:22:41 +0100 (IST) From: Reply-To: To: tgl@sss.pgh.pa.us Subject: Re: Query plan for very large number of joins Cc: pgsql-performance@postgresql.org Mime-Version: 1.0 Content-Type: text/plain;charset="UTF-8" Content-Transfer-Encoding: 7bit X-CP-Disclaimer: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.178 tagged_above=0 required=5 tests=NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200506/67 X-Sequence-Number: 12705 >>> I am using PostgreSQL (7.4) with a schema that was generated >>> automatically (using hibernate). The schema consists of about 650 >>> relations. One particular query (also generated automatically) >>> consists of left joining approximately 350 tables. [snip] >One thought is that I am not sure I believe the conclusion that planning >is taking only 36 ms; even realizing that the exclusive use of left >joins eliminates options for join order, there are still quite a lot of >plans to consider. You should try both EXPLAIN and EXPLAIN ANALYZE >from psql and see how long each takes. It'd also be interesting to keep >an eye on how large the backend process grows while doing this --- maybe >it's being driven into swap. Thanks for the suggestion. I've timed both the EXPLAIN and the EXPLAIN ANALYZE operations. Both operations took 1m 37s. The analyze output indicates that the query execution time was 950ms. This doesn't square with the JDBC prepareStatement executing in 36ms. My guess is that the prepare was actually a no-op but I haven't found anything about this yet. So, is it correct to interpret this as the query planner taking an awful long time? Is it possible to force the query planner to adopt a specific strategy and not search for alternatives (I'm aware of the noXX options, it's the reverse logic that I'm thinking of here). Alternatively, is there some way to check if the query planner is bottlenecking on a specific resource? Finally, PFC was asking about the nature of the application, it's not a specific application just a generic bit of infrastructure consisting of a transformation of the UBL schema. Despite being fairly restricted in scope, the schema is highly denormalized hence the large number of tables. Thanks for all your help. -phil I'm using Vodafone Mail - to get your free mobile email account go to http://www.vodafone.ie Use of Vodafone Mail is subject to Terms and Conditions http://www.vodafone.ie/terms/website