Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 844926501E8 for ; Thu, 21 Aug 2008 14:09:11 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 75747-04-7 for ; Thu, 21 Aug 2008 14:09:02 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mu-out-0910.google.com (mu-out-0910.google.com [209.85.134.188]) by postgresql.org (Postfix) with ESMTP id 3B06064FD04 for ; Thu, 21 Aug 2008 14:08:17 -0300 (ADT) Received: by mu-out-0910.google.com with SMTP id i2so61214mue.3 for ; Thu, 21 Aug 2008 10:08:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=01hms2FdMWNCZ18d31D+bG0rgmjsJiouB8g4ZqGO0P4=; b=otMIual+iDzRaCuiMcn2GIwOPJ5xMGO111x3UPGr7/ayuH7gIWDj9eP5RdhJWomzH2 2OR55zweO9muIfEbl00GOIbZtNeHoH0DoYTa18/isi/uIeDKK/fumBMkoeyCT3q72Tqz 5O3J+ZnbSA20gXOpHQsei5SUUbLnHpRdHf8bU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=DdTX8jk1FTjwzsYIt5YIWU+uqf2v7fTmvnqJkmXH4FN5Sdd7fmKu7at4AZRfszK35v c2hxpTsEtqE30UWVm5rhnSsG8m5He3k/Yt6/p2Zif3BlzAfRZAOx1YK67P25iEuVuRCR 7spPh8oS1aPTT1xv3c/WgEnY22CdH4nMAUEBw= Received: by 10.103.137.19 with SMTP id p19mr1100259mun.108.1219338494389; Thu, 21 Aug 2008 10:08:14 -0700 (PDT) Received: by 10.103.12.18 with HTTP; Thu, 21 Aug 2008 10:08:14 -0700 (PDT) Message-ID: Date: Thu, 21 Aug 2008 13:08:14 -0400 From: "Merlin Moncure" To: "Moritz Onken" Subject: Re: Slow query with a lot of data Cc: pgsql-performance@postgresql.org In-Reply-To: <74E8B5A3-F0E7-4B66-947B-AE7715A55B90@houseofdesign.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <90AA1B69-4E9C-4710-9D58-F65620DDA022@houseofdesign.de> <3663375B-7AC0-43F6-B6EC-D3EE572F3D34@houseofdesign.de> <24E3FBFF-E0B8-435E-ACE1-652E93FE2213@houseofdesign.de> <380CD097-4A33-4134-8C13-B9BF34EC6C63@houseofdesign.de> <7DE7116C-4BBC-4776-AEE0-63A2E2DEAF16@houseofdesign.de> <74E8B5A3-F0E7-4B66-947B-AE7715A55B90@houseofdesign.de> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200808/255 X-Sequence-Number: 31136 On Thu, Aug 21, 2008 at 11:07 AM, Moritz Onken wrote: > > Am 21.08.2008 um 16:39 schrieb Scott Carey: > >> It looks to me like the work_mem did have an effect. >> >> Your earlier queries had a sort followed by group aggregate at the top, >> and now its a hash-aggregate. So the query plan DID change. That is likely >> where the first 10x performance gain came from. > > But it didn't change as I added the sub select. > Thank you guys very much. The speed is now ok and I hope I can finish tihs > work soon. > > But there is another problem. If I run this query without the limitation of > the user id, postgres consumes about 150GB of disk space and dies with > > ERROR: could not write block 25305351 of temporary file: No space left on > device > > After that the avaiable disk space is back to normal. > > Is this normal? The resulting table (setup1) is not bigger than 1.5 GB. Maybe the result is too big. if you explain the query, you should get an estimate of rows returned. If this is the case, you need to rethink your query or do something like a cursor to browse the result. merlin