pg.ddx.io pgsql-performance@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: Gavin Flower <GavinFlower@archidevsys.co.nz>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: Yves Dorfsman <yves@zioup.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: extract(year from date) doesn't use index but maybe could?
Date: Mon, 20 Apr 2015 12:13:12 +1200
Message-ID: <55344498.7070101@archidevsys.co.nz> (raw)
In-Reply-To: <6398.1429482594@sss.pgh.pa.us>
References: <CADhq2b51G0QrjNz_vH6e_SLyu=tR0A0G0zHhFsP7rqRr+6FA3w@mail.gmail.com>
<5533E8F4.2050400@2ndquadrant.com>
<CADhq2b67QTAD7AkhGm3GZMwCUDU6kR70mpKEEnM=S5h1yRtdgg@mail.gmail.com>
<55341A3C.1080101@2ndquadrant.com>
<6287.1429479191@sss.pgh.pa.us>
<5534269A.10605@zioup.com>
<6398.1429482594@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>
On 20/04/15 10:29, Tom Lane wrote:
> Yves Dorfsman <yves@zioup.com> writes:
>> What about functions that are simpler such as upper()/lower()?
> If you think those are simpler, you're much mistaken :-(. For instance,
> "lower(first_name) = 'yves'" would have to be translated to something
> like "first_name IN ('yves', 'yveS', 'yvEs', 'yvES', ..., 'YVES')"
> -- 16 possibilities altogether, or 2^N for an N-character string.
> (And that's just assuming ASCII up/down-casing, never mind the interesting
> rules in some non-English languages.) In a case-sensitive index, those
> various strings aren't going to sort consecutively, so we'd end up needing
> a separate index probe for each possibility.
>
> extract(year from date) agrees with timestamp comparison up to boundary
> cases, that is a few hours either way at a year boundary depending on the
> timezone situation. So you could translate it to a lossy-but-indexable
> timestamp comparison condition and not expect to scan too many index items
> that don't satisfy the original extract() condition. But I don't see how
> to make something like that work for mapping case-insensitive searches
> onto case-sensitive indexes.
>
> regards, tom lane
>
>
Yeah, an event that happened at 2 am Thursday January 1st 2015 in New
Zealand, will be in the year 2014 for people of London in England!
Cheers,
Gavin
--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance
view thread (10+ messages) latest in thread
Message-ID: <55344498.7070101@archidevsys.co.nz> Permalink: ../55344498.7070101@archidevsys.co.nz/ Also on: postgresql.org/message-id/55344498.7070101@archidevsys.co.nz ·
reply
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Reply to all the recipients using the --to and --cc options: reply via email To: pgsql-performance@postgresql.org Cc: GavinFlower@archidevsys.co.nz, tgl@sss.pgh.pa.us, yves@zioup.com Subject: Re: extract(year from date) doesn't use index but maybe could? In-Reply-To: <55344498.7070101@archidevsys.co.nz> * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox