Re: Postmaster won't -HUP - Mailing list pgsql-general

From Tom Lane
Subject Re: Postmaster won't -HUP
Date
Msg-id 26508.959896713@sss.pgh.pa.us
Whole thread Raw
In response to Re: Postmaster won't -HUP  (Jerry Lynde <jlynde@diligence.com>)
Responses Re: Postmaster won't -HUP  (Jerry Lynde <jlynde@diligence.com>)
List pgsql-general
Jerry Lynde <jlynde@diligence.com> writes:
>>>> They are all indexed, the DOB index is actually  DOBYear DOBDay and
>>>> DOBMonth and all 5 fields are indexed
>>
>> Do you have 5 indexes or do you have an index that spans more than one
>> field?

> Sorry for being less than explicit. There are 5 separate indices, one per
> field.

So your query is really something more like

    ... WHERE firstname = 'joe' AND lastname = 'blow' AND
          DOByear = 1999 AND DOBmonth = 1 AND DOBday = 1

?

The problem here is that only one index can be used in any individual
scan.  If I were the optimizer I'd probably figure that lastname is
going to be the most selective of the five available choices, too.

I'd suggest storing the DOB as *one* field of type 'date'.  You can
pull out the subparts for display with date_part() when you need to,
but for searches you'll be a lot better off with

        WHERE DOB = '1999-01-01'

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: btree index and max()
Next
From: Jerry Lynde
Date:
Subject: Re: Postmaster won't -HUP