Re: How to use brin indexes?

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: hubert depesz lubaczewski <depesz(at)gmail(dot)com>
Cc: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: How to use brin indexes?
Date: 2014-11-22 02:29:04
Message-ID: 20141122022904.GS1639@alvin.alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera wrote:
> hubert depesz lubaczewski wrote:
> > > The minmax operator families don't include any cross-type operators. I'm
> > not exactly sure why not.. Alvaro?
> > > Anyway, try "select * from t where id = 1224::int8"
> >
> > It works that way, but it would be great to have it working with non-casted
> > values too.
>
> Yeah. I didn't put in much extra effort because some simple experiments
> worked with cross-type queries; my guess at the time was that the system
> added casts automatically for some cases and that was good enough. But
> there are several examples that don't work all that nicely, so I'm going
> to rework the opfamilies a bit. Stay tuned.

This patch reworks the opfamilies in pretty much the same way btree has
them: each type category has one opfamily, and there are opclasses for
each datatype; then there are enough pg_amop and pg_amproc entries to
cover all the cross-type operators and necessary support functions.
The collapsed types, and the resulting opfamilies, are:

int2, int4, int8 -> integer_minmax_ops
date, timestamp, timestamptz -> datetime_minmax_ops
float4, float8 -> float_minmax_ops

I'm not sure if there should be something involving numeric. Btree
doesn't appear to have it.

Btree also has a "network" opfamily which I initially guessed to contain
inet and cidr, but on looking closer it only has inet. And Brin doesn't
have cidr at all, so I left this alone.

I won't push this right away because I want to add the cross-type stuff
to the tests, to ensure I haven't bollixed anything; I ran a few quick
manual tests and everything seems to work. But if Depesz wants to test
the behavior, be my guest. Note that you need to initdb after
rebuilding with this patch.

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachment Content-Type Size
brin-opfams.patch text/x-diff 25.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marko Tiikkaja 2014-11-22 03:49:26 HINTing on UPDATE foo SET foo.bar = ..;
Previous Message Noah Misch 2014-11-22 01:30:25 Re: Automatic PG_PRINTF_ATTRIBUTE