| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | "Merlin Moncure" <merlin(dot)moncure(at)rcsonline(dot)com> |
| Cc: | pgsql-performance(at)postgresql(dot)org |
| Subject: | Re: best way to fetch next/prev record based on index |
| Date: | 2004-07-27 16:00:38 |
| Message-ID: | 29727.1090944038@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-performance |
I said:
> Oh, wait, you're right --- I'm mis-visualizing the situation.
> Hmm, it sure seems like there ought to be an easy way to do this...
The problem is that a multi-column index doesn't actually have the
semantics you want. If you are willing to consider adding another
index (or replacing the existing 3-column guy), how about
create index ti on t((array[a,b,c]));
select * from t where array[a,b,c] >= array[a1,b1,c1]
order by array[a,b,c]
limit 1 offset 1;
This seems to do the right thing in 7.4 and later. It does require that
all three columns have the same datatype though; you weren't specific
about the data model ...
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Merlin Moncure | 2004-07-27 16:02:17 | Re: best way to fetch next/prev record based on index |
| Previous Message | Tom Lane | 2004-07-27 15:40:07 | Re: best way to fetch next/prev record based on index |