Re: Index scan troubles - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Index scan troubles
Date
Msg-id 16843.1220378619@sss.pgh.pa.us
Whole thread Raw
In response to Index scan troubles  (Markus Wanner <markus@bluegap.ch>)
List pgsql-hackers
Markus Wanner <markus@bluegap.ch> writes:
> I'm having a hard time using an index scan. So far, I've done quite well 
> with ScanKeyInit for equality searches. But now I need to scan an index 
> from a given starting point. Something like:

>     (x, y, z,...) > (const, const, const,...)

> For the equality operatior, I've used get_sort_group_operators() in 
> combination with get_opcode() to pass that on as the sk_func of the scan 
> key. I slowly begin to doubt if that's correct at all.

> While it works for equality scans, it does somehow not work for for 
> BTGreaterStrategy. What am I missing?

A row comparison (a,b,c) > (x,y,z) means something entirely different
from a>x AND b>y AND c>z; but it sounds like the keys you are creating
define the latter condition.

Look at the RowCompareExpr stuff in nodeIndexscan.c to see how to build
a scankey that means the former.
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Neil Conway"
Date:
Subject: Re: Window functions patch v04 for the September commit fest
Next
From: Tom Lane
Date:
Subject: Re: Mysterious Bus Error with get_fn_expr_argtype()