Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fmp3E-0002jU-5f for pgsql-general@arkaria.postgresql.org; Mon, 06 Aug 2018 23:36:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fmp3C-0004mV-1N for pgsql-general@arkaria.postgresql.org; Mon, 06 Aug 2018 23:36:34 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fmp3A-0004mM-6R for pgsql-general@lists.postgresql.org; Mon, 06 Aug 2018 23:36:33 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fmp35-000856-9B for pgsql-general@postgresql.org; Mon, 06 Aug 2018 23:36:30 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 862DF26F; Mon, 6 Aug 2018 19:36:25 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 06 Aug 2018 19:36:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=T4caNZSaJKeWCewBVWMMBftvk5ehf Nl4m9OU60WMkZ8=; b=lnH9TqbvJ8sYG4iDfnosrmSRpOBjqXw6pSvKNzmRkQMb7 GBornv34/J3RePsCWwhxWIe8c1WSv56FtcFMDG0qIcfSzqVFDXaUsi731FLmy/Vd dxd3XC9f0D9tObCBZH7DII//+BRNIyV61XOPeUpw3QmxE4d40wF3swaYaSu3w5Qt vYkT8QEG0OUd5nqg1Hwft7XkLDegTuQ9HfOmXRHXAy9oo8Qs6GJUlD4mjNsf7s2Y 2UOXSqhyQQCg+dTne/gsbcmDfbh84fJ9QKm4wpZtDFvZqMhJnAGcSqJnYi9hoZHW 6PPErD+mIcEfoLIMfP+UKFFBHSmQYtYeSviCEoayA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=T4caNZ SaJKeWCewBVWMMBftvk5ehfNl4m9OU60WMkZ8=; b=SlmFLh/DU2kIPBfiLsK7vt y3a0/L9dd9gQ0aLNyFFYs37xgO3QtcgTE+PE7ZC7aHn4/85fgQVZ2hcdymFSs2QN KTVgDzghEdul7NTc26FW3esMd/6FwxgXI4s6Uyd/M5wggo9kqgh8BGwFFHwMw2sB EsirAtEKcC/tJ3RqrZfqHUORPobv/qHlT9jB8eLTzPVK16GcQA+6aHZrXDzjYbC0 XsRUS6MKTJ8P7zwkA+yc3gHTwdkpLp+/zjhRKyjnErnCYw8LMypGcAJmeDXtq0jd a+dnqIytcrC+7dObUft9/GgoXytwBLHm8cb5ahGBZWEOKFmYUqqDZVNFHHMZQX6A == X-ME-Proxy: X-ME-Sender: Received: from [192.168.1.3] (unknown [71.212.134.181]) by mail.messagingengine.com (Postfix) with ESMTPA id 92AE710268; Mon, 6 Aug 2018 19:36:24 -0400 (EDT) Subject: Re: Immutable function WAY slower than Stable function? To: Ken Tanzer , PG-General Mailing List References: From: Adrian Klaver Message-ID: <03120a03-75d0-ad6c-691c-35ca7e7fccfa@aklaver.com> Date: Mon, 6 Aug 2018 16:36:23 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 08/06/2018 03:49 PM, Ken Tanzer wrote: > Hi.  I was recently troubleshooting a function, and realized it had > incorrectly been declared as Immutable, when it should have been > declared Stable.  When I changed it to Stable, the query I was running > ran dramatically faster. Digging into this a little more, this is what I > found: > > > Happy to provide any additional relevant info, or for someone to point > out what obvious thing I'm overlooking.  Thanks in advance! What is the definition for target_date()? > > Ken > > > > -- -- Adrian Klaver adrian.klaver@aklaver.com