Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UXZIH-0006Ax-9t for pgsql-performance@arkaria.postgresql.org; Wed, 01 May 2013 15:50:09 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UXZIG-0004V2-QW for pgsql-performance@arkaria.postgresql.org; Wed, 01 May 2013 15:50:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UXZDL-0003Ls-Fm for pgsql-performance@postgresql.org; Wed, 01 May 2013 15:45:03 +0000 Received: from kinkrsoftware.nl ([2a00:90c0:200::2eff:fea7:a060]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UXZDH-0005lz-6c for pgsql-performance@postgresql.org; Wed, 01 May 2013 15:45:03 +0000 Received: from localhost (localhost [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by kinkrsoftware.nl (Postfix) with ESMTPSA id 3C29A2F08; Wed, 1 May 2013 17:44:57 +0200 (CEST) Date: Wed, 1 May 2013 17:44:54 +0200 (CEST) From: Stefan de Konink X-X-Sender: skinkie@kinkrsoftware.nl To: Tom Lane cc: pgsql-performance@postgresql.org Subject: Re: [BUGS] BUG #8130: Hashjoin still gives issues In-Reply-To: <3469.1367421052@sss.pgh.pa.us> Message-ID: References: <3469.1367421052@sss.pgh.pa.us> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Dear Tom, On Wed, 1 May 2013, Tom Lane wrote: >> What can we do to provide a bit more of information? > > https://wiki.postgresql.org/wiki/Slow_Query_Questions > > There is no particularly good reason to think this is a bug; please > take it up on pgsql-performance if you have more questions. I beg to disagree, the performance of a select * query and the select b.id query are both "hot". The result in a fundamentally different query plan (and performance). Combined with the recent bugfix regarding hash estimation, it gives me a good indication that there might be a bug. I am not deep into the query optimiser of PostgreSQL but given the above same were different selections can change an entire query plan (and * is in fact out of the box 30 times faster than b.id) it does. When hash is disabled the entire query is -depending on the system checked- 2 to 30x faster. The original query: select * from ambit_privateevent_calendars as a, ambit_privateevent as b, ambit_calendarsubscription as c, ambit_calendar as d where c.calendar_id = d.id and a.privateevent_id = b.id and c.user_id = 1270 and c.calendar_id = a.calendar_id and c.STATUS IN (1, 8, 2, 15, 18, 4, 12, 20) and not b.main_recurrence = true; select b.id from ambit_privateevent_calendars as a, ambit_privateevent as b, ambit_calendarsubscription as c, ambit_calendar as d where c.calendar_id = d.id and a.privateevent_id = b.id and c.user_id = 1270 and c.calendar_id = a.calendar_id and c.STATUS IN (1, 8, 2, 15, 18, 4, 12, 20) and not b.main_recurrence = true; (select * => select b.id, the star query is *fastest*) We compare: http://explain.depesz.com/s/jRx http://explain.depesz.com/s/eKE By setting "set enable_hashjoin = off;" performance in our entire application increased 30 fold in throughput, which was a bit unexpected but highly appreciated. The result of the last query switch the mergejoin: http://explain.depesz.com/s/AWB It is also visible that after hashjoin is off, the b.id query is faster than the * query (what would be expected). Our test machine is overbudgetted, 4x the memory of the entire database ~4GB, and uses the PostgreSQL stock settings. Stefan -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance