X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 28738329C82 for ; Wed, 22 Sep 2004 11:44:33 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 10604-02 for ; Wed, 22 Sep 2004 10:44:27 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 9DCF5329C6B for ; Wed, 22 Sep 2004 11:44:28 +0100 (BST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i8MAiQfg012278 for ; Wed, 22 Sep 2004 10:44:26 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i8MAS7Vu007190 for pgsql-performance@postgresql.org; Wed, 22 Sep 2004 10:28:07 GMT From: Gaetano Mendola X-Newsgroups: comp.databases.postgresql.performance Subject: Re: 7.4 vs 7.3 ( hash join issue ) Date: Wed, 22 Sep 2004 12:28:04 +0200 Organization: PYRENET Midi-pyrenees Provider Lines: 65 Message-ID: <415153B4.5040902@bigfoot.com> References: <4151362C.6070106@bigfoot.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@pyrenet.fr To: Dennis Bjorklund User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en In-Reply-To: X-Enigmail-Version: 0.86.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/214 X-Sequence-Number: 8342 Dennis Bjorklund wrote: > On Wed, 22 Sep 2004, Gaetano Mendola wrote: > > >> Limit (cost=10.21..10.21 rows=1 width=24) (actual time=0.885..0.885 rows=0 loops=1) >> Limit (cost=10.28..10.28 rows=1 width=24) (actual time=0.429..0.429 rows=0 loops=1) > > > These estimated costs are almost the same, but the runtime differs a bit. > This means that maybe you need to alter settings like random_page_cost, > effective_cache and maybe some others to make the cost reflect the runtime > better. > > Since the costs are so close to each other very small changes can make it > choose the other plan. It's also very hard to make an estimate that is > correct in all situations. That's why it's called an estimate after all. Is not feseable. That values are obtained with random_page_cost = 2, effective_cache_size = 20000, cpu_tuple_cost = 0.01 increasing or decreasing random_page_cost this means increase or decrease both costs: random_page_cost = 1.5 hashjoin on => 8.47 hashjoin off => 8.53 random_page_cost = 3 hashjoin on => 13.70 hashjoin off => 13.76 so is choosen the hasjoin method in both cases. In the other side the effective_cache_size doesn't affect this costs. Decreasing the cpu_tuple_cost have the same effect cpu_tuple_cost = 0.005 hashjoin on => 10.11 hashjoin off => 10.17 cpu_tuple_cost = 0.001 hashjoin on => 10.03 hashjoin off => 10.03 cpu_tuple_cost = 0.0005 hashjoin on => 10.01 hashjoin off => 10.01 And when the two costs are the same the hashjoin path is choosen. I think cpu_tuple_cost less then 0.001 is not a good idea I think the only way is set the hashjoin = off. Any other suggestion ? Regards Gaetano Mendola