| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> | 
|---|---|
| To: | Bruno Wolff III <bruno(at)wolff(dot)to> | 
| Cc: | "Kaitharam, Ananth" <AKaitharam(at)gomez(dot)com>, "'pgsql-novice(at)postgresql(dot)org'" <pgsql-novice(at)postgresql(dot)org> | 
| Subject: | Re: Indexed access for INET/ CIDR datatype | 
| Date: | 2003-06-19 17:57:57 | 
| Message-ID: | 10102.1056045477@sss.pgh.pa.us | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-novice | 
Bruno Wolff III <bruno(at)wolff(dot)to> writes:
> On Tue, Jun 17, 2003 at 08:25:04 -0400,
>   "Kaitharam, Ananth" <AKaitharam(at)gomez(dot)com> wrote:
>> Is there a way to index the >>= or <<= operators for CIDR/ INET datatypes? I
>> built a btree index, which works for the = clause, but not the others.
> I don't think so.
There are some provisions for turning <<= tests into range scans,
for example
regression=# create table foo (f1 inet unique);
NOTICE:  CREATE TABLE / UNIQUE will create implicit index 'foo_f1_key' for table 'foo'
CREATE TABLE
regression=# explain select * from foo where f1 <<= '127.0/16';
                                   QUERY PLAN
--------------------------------------------------------------------------------
 Index Scan using foo_f1_key on foo  (cost=0.00..17.07 rows=500 width=32)
   Index Cond: ((f1 >= '127.0.0.0/16'::inet) AND (f1 <= '127.0.255.255'::inet))
   Filter: (f1 <<= '127.0.0.0/16'::inet)
(3 rows)
I believe you have to write "field <<= constant" to get this to happen.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Kaitharam, Ananth | 2003-06-19 18:27:46 | Re: Indexed access for INET/ CIDR datatype | 
| Previous Message | Bruno Wolff III | 2003-06-19 17:00:44 | Re: Indexed access for INET/ CIDR datatype |