Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YjxLD-0007r7-Bw for pgsql-performance@arkaria.postgresql.org; Sun, 19 Apr 2015 22:05:27 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YjxLC-0002aV-4r for pgsql-performance@arkaria.postgresql.org; Sun, 19 Apr 2015 22:05:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YjxLB-0002aJ-B1 for pgsql-performance@postgresql.org; Sun, 19 Apr 2015 22:05:25 +0000 Received: from smtp-out-02.shaw.ca ([64.59.136.138]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YjxL6-0007L9-6Q for pgsql-performance@postgresql.org; Sun, 19 Apr 2015 22:05:23 +0000 X-Cloudmark-SP-Filtered: true X-Cloudmark-SP-Result: v=1.1 cv=UbGOdjJMTOnDdlSKs4VLEv47Nwxh2hlhayjdFxkzNJk= c=1 sm=1 a=tJe01QhAHdwA:10 a=BLceEmwcHowA:10 a=IkcTkHD0fZMA:10 a=1AzCEyHvRsrOnBOCSdCQag==:17 a=N8iSzGwtAAAA:8 a=B0wtvfRnune1lAaH2pYA:9 a=QEXdDO2ut3YA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 Received: from unknown (HELO home.zioup.com) ([70.72.160.156]) by smtp-out-02.shaw.ca with ESMTP; 19 Apr 2015 16:05:16 -0600 Received: from [192.168.133.30] (unknown [184.70.121.206]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by home.zioup.com (Postfix) with ESMTPSA id 32733A00EF for ; Sun, 19 Apr 2015 16:05:16 -0600 (MDT) Message-ID: <5534269A.10605@zioup.com> Date: Sun, 19 Apr 2015 16:05:14 -0600 From: Yves Dorfsman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: extract(year from date) doesn't use index but maybe could? References: <5533E8F4.2050400@2ndquadrant.com> <55341A3C.1080101@2ndquadrant.com> <6287.1429479191@sss.pgh.pa.us> In-Reply-To: <6287.1429479191@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.6 (--) 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 2015-04-19 15:33, Tom Lane wrote: > >> It's possible that in the future someone will implement an optimization >> like this, but I'm not aware of anyone working on that and I wouldn't >> hold my breath. > > Yeah. In principle you could make the planner do this. As Adam Williams > notes nearby, there's a problem with lack of exact consistency between > extract() semantics and straight timestamp comparisons; but you could > handle that by extracting indexable expressions that are considered lossy, What about functions that are simpler such as upper()/lower()? On 9.3, this: `select email from users where lower(first_name) = 'yves'; is not using the index on first_name (Seq Scan on first_name). This should be easy to implement? -- http://yves.zioup.com gpg: 4096R/32B0F416 -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance