Received: from maia.hub.org (maia-4.hub.org [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 8F9316340A4 for ; Thu, 20 May 2010 16:22:14 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 12588-05; Thu, 20 May 2010 19:22:07 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id EA60E63247B; Thu, 20 May 2010 16:22:06 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o4KJLnNs007410; Thu, 20 May 2010 15:21:49 -0400 (EDT) To: krzysztof.nienartowicz@cern.ch cc: pgsql-bugs@postgresql.org, pgsql-performance@postgresql.org Subject: Re: Query causing explosion of temp space with join involving partitioning In-reply-to: References: Comments: In-reply-to Krzysztof Nienartowicz message dated "Thu, 20 May 2010 16:00:03 +0200" Date: Thu, 20 May 2010 15:21:49 -0400 Message-ID: <7409.1274383309@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201005/155 X-Sequence-Number: 26817 Krzysztof Nienartowicz writes: > surveys-> SELECT t1.SURVEY_PK, t1.SOURCE_PK, t1.TSTYPE, t1.VALS > surveys-> FROM sources t0 ,TS t1 where > surveys-> (t0.SURVEYID = 16 AND t0.SRCID >= 203510110032281 AND > t0.SRCID <= 203520107001677 and t0.SURVEYID = t1.SURVEY_PK AND t0.SRCID = > t1.SOURCE_PK ) ORDER BY t0.SURVEYID ASC, t0.SRCID ASC We don't make any attempt to infer derived inequality conditions, so no, those constraints on t0.srcid won't be propagated over to t1.source_pk. Sorry. It's been suggested before, but it would be a lot of new mechanism and expense in the planner, and for most queries it'd just slow things down to try to do that. > I have around 30 clients running the same query with different > parameters, but the query always returns 1000 rows (boundary values > are pre-calculated,so it's like traversal of the equiwidth histogram > if it comes to srcid/source_pk) and the rows from parallel queries > cannot be overlapping. Usually query returns within around a second. > I noticed however there are some queries that hang for many hours and > what is most curious some of them created several GB of temp files. Can you show us the query plan for the slow cases? regards, tom lane