Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WRz0K-0005lE-5w for pgsql-performance@arkaria.postgresql.org; Mon, 24 Mar 2014 07:09:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WRz0J-0001vQ-JC for pgsql-performance@arkaria.postgresql.org; Mon, 24 Mar 2014 07:09:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WRz0H-0001vH-Fc for pgsql-performance@postgresql.org; Mon, 24 Mar 2014 07:09:01 +0000 Received: from smtp-outbound-1.vmware.com ([208.91.2.12]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WRz08-00065H-KW for pgsql-performance@postgresql.org; Mon, 24 Mar 2014 07:08:59 +0000 Received: from sc9-mailhost1.vmware.com (sc9-mailhost1.vmware.com [10.113.161.71]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id 8931B28315; Mon, 24 Mar 2014 00:08:49 -0700 (PDT) Received: from zcs-prod-ext-mta-1.vmware.com (zcs-prod-ext-mta-1.vmware.com [10.113.62.223]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 8495018330; Mon, 24 Mar 2014 00:08:49 -0700 (PDT) Received: from zcs-prod-ext-mta-1.vmware.com (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTP id D3BD712002F; Mon, 24 Mar 2014 00:08:44 -0700 (PDT) Received: from [192.168.1.90] (zimbra-prod-ext-proxy-vip.vmware.com [10.113.63.87]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTPSA; Mon, 24 Mar 2014 00:08:43 -0700 (PDT) Message-ID: <532FD9FE.9000501@vmware.com> Date: Mon, 24 Mar 2014 09:08:46 +0200 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131103 Icedove/17.0.10 MIME-Version: 1.0 To: Erik van Zijst CC: pgsql-performance@postgresql.org Subject: Re: Suboptimal query plan when using expensive BCRYPT functions References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -7.4 (-------) 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 On 03/22/2014 02:59 AM, Erik van Zijst wrote: > Is there any way I can get postgres to perform the hash calculations > on the *result* of the other parts of the where clause, instead of the > other way around? Or else rewrite the query? The planner doesn't know that the crypt function is expensive. That can be fixed with "ALTER FUNCTION crypt(text, text) COST ". Even with that, I'm not sure if the planner is smart enough to optimize the query the way you'd want, but it's worth a try. - Heikki -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance