Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 12A7AB5DC0A for ; Tue, 24 May 2011 11:35:06 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 93305-03 for ; Tue, 24 May 2011 14:34:58 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sam.nabble.com (sam.nabble.com [216.139.236.26]) by mail.postgresql.org (Postfix) with ESMTP id F0DBEB5DBDA for ; Tue, 24 May 2011 11:34:57 -0300 (ADT) Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1QOshF-0004Ku-8r for pgsql-performance@postgresql.org; Tue, 24 May 2011 07:34:57 -0700 Date: Tue, 24 May 2011 07:34:57 -0700 (PDT) From: panam To: pgsql-performance@postgresql.org Message-ID: <1306247697267-4422247.post@n5.nabble.com> In-Reply-To: <4DDB47BC.8030504@postnewspapers.com.au> References: <1306210464806-4420974.post@n5.nabble.com> <4DDB47BC.8030504@postnewspapers.com.au> Subject: Re: Hash Anti Join performance degradation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.767 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, T_TO_NO_BRKTS_FREEMAIL=0.01, URI_HEX=1.122 X-Spam-Level: X-Archive-Number: 201105/324 X-Sequence-Number: 43833 Hi Craig and C=C3=A9dric, Thanks for the very informative introduction to the netiquette here and thanks for sharing your time. I wasn't aware of http://explain.depesz.com/, very useful. So, here are the query plans: http://explain.depesz.com/s/6AU (1st from previous post, good) http://explain.depesz.com/s/YPS (2nd from previous post, bad) > The usual cause is that the statistics for estimated row counts cross a= =20 > threshold that makes the query planner think that a different kind of=20 > plan will be faster. Hm, as far as i understand the plans, they are equivalent, aren't they? > If the query planner is using bad information about the performance of=20 > the storage, then it will be making bad decisions about which approach=20 > is faster. So the usual thing to do is to adjust seq_page_cost and=20 > random_page_cost to more closely reflect the real performance of your=20 > hardware, and to make sure that effective_cache_size matches the real=20 > amount of memory your computer has free for disk cache use. Will this make any difference even when the plans are equivalent as assumed above? The table creation SQL is as follows: http://pastebin.com/qFDUP7Aa (Message table); ~ 2328680=09rows, is growing constantly (~ 10000 new rows each day),=20 http://pastebin.com/vEmh4hb8 (Box table); ~ 128=09rows (growing very slowly= 1 row every two days, each row updated about 2x a day) The DB contains the same data, except that for the "good" query, the last 10976 rows (0.4%) of message are removed by doing a DELETE FROM message where timestamp > TO_DATE ('05/23/2011','mm/dd/yyyy'); This speeds up the query by a factor of ~27. (207033.081 (bad) vs. 7683.978 (good)). Each query was run before and after a vacuum analyze, one time to create appropriate statistics, and the second time to do the actual measurement. All tests were made on the dev-machine, which is a 8GB, Core i7, Windows 7 I experienced the issue at first on the "production"-environment, which is = a 64-bit Ubuntu, running PostgreSQL 9.0.1 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46), 64-bit, and later for analysis on the dev-environment, which is a 64-bit Windows 7, running PostgreSQL 9.0.4, compiled by Visual C++ build 1500, 64-bit For testing, I've increased the buffers that I judge important for the issu= e to the following values: effective_cache_size: 4GB shared_buffers: 1GB work_mem: 1GB temp_buffers: 32MB After that, configuration was reloaded and the postgresql service was restarted using pgAdmin. Interestingly, there was no performance gain as compared to the default settings, the "bad" query even took about 30 seconds (15%) longer. As well it seems, all data fit into memory, so there is not much disk I/O involved. @C=C3=A9dric > did you have log of vacuum and checkpoint activity ? > (no vacuum full/cluster or such thing running ?) There is no clustering involved here, its a pretty basic setup. How can I obtain the information you require here? I could send you the output of the analyse vacuum command from pgAdmin, but is there a way to make it output the information in English (rather than German)?=20 Thanks for your interest in this issue. Regards, panam -- View this message in context: http://postgresql.1045698.n5.nabble.com/Hash-= Anti-Join-performance-degradation-tp4420974p4422247.html Sent from the PostgreSQL - performance mailing list archive at Nabble.com.