Re: best way to fetch next/prev record based on index - Mailing list pgsql-performance

From Markus Schaber
Subject Re: best way to fetch next/prev record based on index
Date
Msg-id 20040727165044.0549286e@kingfisher.intern.logi-track.com
Whole thread Raw
In response to best way to fetch next/prev record based on index  ("Merlin Moncure" <merlin.moncure@rcsonline.com>)
List pgsql-performance
Hi, Merlin,

On Tue, 27 Jul 2004 10:21:32 -0400
"Merlin Moncure" <merlin.moncure@rcsonline.com> wrote:

> The basic problem is the planner can't always match the query to the
> index.  So, either the planner has to be helped/fixed or I have to
> explore another solution.  This seems to happen most when the 'a'
> column has very poor selectivity.  In this case, the planner will only
> examine the 'a' part of the key.

So it may help to add some more indices so you have an index for all permutations,

Create an index on (a,b,c), (a,c,b), (b,c,a), (b,a,c), (c,a,b) and (c,b,a).

So as long as one of the rows has enough selectivity, the planner should
be able to select the correct index. Maybe increasing the number of
random samples for the rows is useful.

HTH,
Markus

--
markus schaber | dipl. informatiker
logi-track ag | rennweg 14-16 | ch 8001 zürich
phone +41-43-888 62 52 | fax +41-43-888 62 53
mailto:schabios@logi-track.com | www.logi-track.com

pgsql-performance by date:

Previous
From: andrew@pillette.com
Date:
Subject: Re: best way to fetch next/prev record based on index
Next
From: "Merlin Moncure"
Date:
Subject: Re: best way to fetch next/prev record based on index