X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 08FC59FA5FB for ; Tue, 30 May 2006 12:17:03 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 25187-10 for ; Tue, 30 May 2006 12:16:51 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from pjetlic.mobart.hr (pjetlic.mobart.hr [80.80.51.10]) by postgresql.org (Postfix) with ESMTP id 18C959FA7B6 for ; Tue, 30 May 2006 12:16:51 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by pjetlic.mobart.hr (Postfix) with ESMTP id C4A0D17A97; Tue, 30 May 2006 17:16:49 +0200 (CEST) Received: from pjetlic.mobart.hr ([127.0.0.1]) by localhost (pjetlic [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 26771-03-2; Tue, 30 May 2006 17:16:49 +0200 (CEST) Received: from mike.mobart.hr (mike.mobart.hr [192.168.10.94]) (using SSLv3 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by pjetlic.mobart.hr (Postfix) with ESMTP id AB08C17A95; Tue, 30 May 2006 17:16:49 +0200 (CEST) Subject: Re: Speedup hint needed, if available? :) From: Mario Splivalo Reply-To: mario.splivalo@mobart.hr To: Tom Lane Cc: pgsql-performance@postgresql.org In-Reply-To: <23931.1149001555@sss.pgh.pa.us> References: <1148998681.18422.24.camel@localhost.localdomain> <23931.1149001555@sss.pgh.pa.us> Content-Type: text/plain Organization: Mob-Art Date: Tue, 30 May 2006 17:16:40 +0200 Message-Id: <1149002200.18422.41.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by OpenSource AV+AS Mail Server X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/526 X-Sequence-Number: 19313 On Tue, 2006-05-30 at 11:05 -0400, Tom Lane wrote: > Do you have realistic test data? The EXPLAIN shows that this is pulling > 275366 of the 826032 rows in the two tables, which seems like rather a > lot for a single user. If it's reasonable that the query needs to fetch > one-third of the data, then you should resign yourself to it taking > awhile :-( I'd say so, yes. The user_subscription table now has only six rows, but the number of actions (giving/taking credits) for a user could easily be as high as 50.000. > If the expected number of matching rows were much smaller, it would > make sense to use indexscans over the two big tables, but unfortunately > existing PG releases don't know how to generate an indexscan join > with a UNION ALL in between :-(. FWIW, 8.2 will be able to do it. > In current releases the only thing I can suggest is to merge > user_subscription_credits_given and user_subscription_credits_taken > into one table so you don't need the UNION ALL. See, that's an idea! :) Thnx, I'll try that. Is it inapropriate to ask about rough estimate on availableness of 8.2? :) Mario -- Mario Splivalo Mob-Art mario.splivalo@mobart.hr "I can do it quick, I can do it cheap, I can do it well. Pick any two."