Re: [GENERAL] Backwards index scan

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dmitry Tkach <dmitry(at)openratings(dot)com>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [GENERAL] Backwards index scan
Date: 2003-12-21 01:28:36
Message-ID: 17667.1071970116@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-general pgsql-hackers

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
> Dmitry Tkach <dmitry(at)openratings(dot)com> writes:
>> This is because there are *lots* (a few million) of matches for x=10,
>> and _bt_first () scans through them *all* sequentually to get to the
>> last one.

> It's not a bug, but I agree that _bt_first can be inefficient if there
> are lots of matching keys.

> I think what we'd want is variant versions of _bt_search and _bt_binsrch
> that locate the first entry greater than the specified target key,
> rather than the first entry greater than or equal to it. Given such
> positioning, all the _bt_first cases that involve stepping over more
> than one entry could be improved to require no more than one step.

I have committed a fix into 7.5devel to do this properly. I think this
is the last case wherein btree is unnecessarily inefficient for large
numbers of equal keys.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2003-12-21 02:03:37 Re: make check and OSX
Previous Message Theodore Petrosky 2003-12-20 20:51:33 make check and OSX

Browse pgsql-general by date

  From Date Subject
Next Message Christopher Kings-Lynne 2003-12-21 01:46:41 Re: PostgreSQL speakers needed for OSCON 2004
Previous Message Guillaume Houssay 2003-12-21 01:14:56 SELECT ... FOR UPDATE

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Kings-Lynne 2003-12-21 01:46:41 Re: PostgreSQL speakers needed for OSCON 2004
Previous Message Tom Lane 2003-12-20 18:48:23 Re: Why isn't DECLARE CURSOR ... FOR UPDATE supported?