Re: Surprised by index choice for count(*)

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Rob Sargent <robjsargent(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Surprised by index choice for count(*)
Date: 2018-05-01 16:07:49
Message-ID: CAKFQuwZR4mibLsfe2YtECMz3jpKACukVTs3abdBTiVx4yxrSog@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, May 1, 2018 at 8:46 AM, Rob Sargent <robjsargent(at)gmail(dot)com> wrote:

> Should I be? I would have thought the pk would have been chosen v.
> function index?
> Indexes:
> "segment_pkey" PRIMARY KEY, btree (id)
> "useg" UNIQUE, btree (probandset_id, chrom, startbase, endbase)
> "fpv" btree (pv(events_less, events_equal, events_greater, 0))
> "segment_markerset_id_probandset_id_idx" btree (markerset_id,
> probandset_id)
>

​Haven't looked at the code but among those 4 indexes the one that was
chosen is the one that comes first alphabetically.​ Ideally it would avoid
multi-column indexes since they are larger; and I believe that a float is
smaller than a uuid so not only alphabetically but the fpv index wins on
size too.

That the index is functional is immaterial here.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2018-05-01 16:11:12 Re: Surprised by index choice for count(*)
Previous Message Rob Sargent 2018-05-01 15:46:51 Surprised by index choice for count(*)