Gin index on array of uuid

Started by M Enriquealmost 10 years ago7 messageshackers
Jump to latest
#1M Enrique
enrique.mailing.lists@gmail.com

Currently creating an index on an array of UUID involves defining an
operator class. I was wondering if this would be a valid request to add as
part of the uuid-ossp extension? This seems like a reasonable operator to
support as a default for UUIDs. Any downsides to adding this as a default?

http://stackoverflow.com/questions/19959735/postgresql-gin-index-on-array-of-uuid

This is the definition from the stack overflow reference:

CREATE OPERATOR CLASS _uuid_ops DEFAULT
FOR TYPE _uuid USING gin AS
OPERATOR 1 &&(anyarray, anyarray),
OPERATOR 2 @>(anyarray, anyarray),
OPERATOR 3 <@(anyarray, anyarray),
OPERATOR 4 =(anyarray, anyarray),
FUNCTION 1 uuid_cmp(uuid, uuid),
FUNCTION 2 ginarrayextract(anyarray, internal, internal),
FUNCTION 3 ginqueryarrayextract(anyarray, internal, smallint,
internal, internal, internal, internal),
FUNCTION 4 ginarrayconsistent(internal, smallint, anyarray, integer,
internal, internal, internal, internal),
STORAGE uuid;

This would be helpful for people trying to use arrays of UUIDs in cloud
environments which limit root access.

Thank you,
Enrique

In reply to: M Enrique (#1)
Re: Gin index on array of uuid

On Tue, Jun 21, 2016 at 11:42 AM, Enrique MailingLists
<enrique.mailing.lists@gmail.com> wrote:

This would be helpful for people trying to use arrays of UUIDs in cloud
environments which limit root access.

I have personally seen numerous requests for this from users of Heroku
Postgres. So, I agree that there is a demand for this.

--
Peter Geoghegan

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: M Enrique (#1)
Re: Gin index on array of uuid

Enrique MailingLists <enrique.mailing.lists@gmail.com> writes:

Currently creating an index on an array of UUID involves defining an
operator class. I was wondering if this would be a valid request to add as
part of the uuid-ossp extension? This seems like a reasonable operator to
support as a default for UUIDs.

This makes me itch, really, because if we do this then we should logically
do it for every other add-on type.

It seems like we are not that far from being able to have just one GIN
opclass on "anyarray". The only parts of this declaration that are
UUID-specific are the comparator function and the storage type, both of
which could be gotten without that much trouble, one would think.

Any downsides to adding this as a default?

Well, it'd likely break things at dump/reload time for people who had
already created a competing "default for _uuid" opclass manually. I'm not
entirely sure, but possibly replacing the core opclasses with a single one
that is "default for anyarray" could avoid such failures. We'd have to
figure out ambiguity resolution rules.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4M Enrique
enrique.mailing.lists@gmail.com
In reply to: Tom Lane (#3)
Re: Gin index on array of uuid

What's a good source code entry point to review how this is working for
anyarray currently? I am new to the postgres code. I spend some time
looking for it but all I found is the following (which I have not been able
to decipher yet).

[image: pasted1]

Thank you,
Enrique

On Tue, Jun 21, 2016 at 12:20 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

Show quoted text

Enrique MailingLists <enrique.mailing.lists@gmail.com> writes:

Currently creating an index on an array of UUID involves defining an
operator class. I was wondering if this would be a valid request to add

as

part of the uuid-ossp extension? This seems like a reasonable operator to
support as a default for UUIDs.

This makes me itch, really, because if we do this then we should logically
do it for every other add-on type.

It seems like we are not that far from being able to have just one GIN
opclass on "anyarray". The only parts of this declaration that are
UUID-specific are the comparator function and the storage type, both of
which could be gotten without that much trouble, one would think.

Any downsides to adding this as a default?

Well, it'd likely break things at dump/reload time for people who had
already created a competing "default for _uuid" opclass manually. I'm not
entirely sure, but possibly replacing the core opclasses with a single one
that is "default for anyarray" could avoid such failures. We'd have to
figure out ambiguity resolution rules.

regards, tom lane

Attachments:

pasted1image/png; name=pasted1Download+1-0
#5Oleg Bartunov
oleg@sai.msu.su
In reply to: M Enrique (#4)
Re: Gin index on array of uuid

On Wed, Jun 29, 2016 at 6:17 AM, M Enrique <enrique.mailing.lists@gmail.com>
wrote:

What's a good source code entry point to review how this is working for
anyarray currently? I am new to the postgres code. I spend some time
looking for it but all I found is the following (which I have not been able
to decipher yet).

Look on https://commitfest.postgresql.org/4/145/

Show quoted text

[image: pasted1]

Thank you,
Enrique

On Tue, Jun 21, 2016 at 12:20 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

Enrique MailingLists <enrique.mailing.lists@gmail.com> writes:

Currently creating an index on an array of UUID involves defining an
operator class. I was wondering if this would be a valid request to add

as

part of the uuid-ossp extension? This seems like a reasonable operator

to

support as a default for UUIDs.

This makes me itch, really, because if we do this then we should logically
do it for every other add-on type.

It seems like we are not that far from being able to have just one GIN
opclass on "anyarray". The only parts of this declaration that are
UUID-specific are the comparator function and the storage type, both of
which could be gotten without that much trouble, one would think.

Any downsides to adding this as a default?

Well, it'd likely break things at dump/reload time for people who had
already created a competing "default for _uuid" opclass manually. I'm not
entirely sure, but possibly replacing the core opclasses with a single one
that is "default for anyarray" could avoid such failures. We'd have to
figure out ambiguity resolution rules.

regards, tom lane

Attachments:

pasted1image/png; name=pasted1Download+1-0
#6M Enrique
enrique.mailing.lists@gmail.com
In reply to: Oleg Bartunov (#5)
Re: Gin index on array of uuid

Thank you.

On Tue, Jun 28, 2016 at 11:06 PM Oleg Bartunov <obartunov@gmail.com> wrote:

Show quoted text

On Wed, Jun 29, 2016 at 6:17 AM, M Enrique <
enrique.mailing.lists@gmail.com> wrote:

What's a good source code entry point to review how this is working for
anyarray currently? I am new to the postgres code. I spend some time
looking for it but all I found is the following (which I have not been able
to decipher yet).

Look on https://commitfest.postgresql.org/4/145/

[image: pasted1]

Thank you,
Enrique

On Tue, Jun 21, 2016 at 12:20 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

Enrique MailingLists <enrique.mailing.lists@gmail.com> writes:

Currently creating an index on an array of UUID involves defining an
operator class. I was wondering if this would be a valid request to

add as

part of the uuid-ossp extension? This seems like a reasonable operator

to

support as a default for UUIDs.

This makes me itch, really, because if we do this then we should
logically
do it for every other add-on type.

It seems like we are not that far from being able to have just one GIN
opclass on "anyarray". The only parts of this declaration that are
UUID-specific are the comparator function and the storage type, both of
which could be gotten without that much trouble, one would think.

Any downsides to adding this as a default?

Well, it'd likely break things at dump/reload time for people who had
already created a competing "default for _uuid" opclass manually. I'm
not
entirely sure, but possibly replacing the core opclasses with a single
one
that is "default for anyarray" could avoid such failures. We'd have to
figure out ambiguity resolution rules.

regards, tom lane

Attachments:

pasted1image/png; name=pasted1Download+1-0
#7M Enrique
enrique.mailing.lists@gmail.com
In reply to: Tom Lane (#3)
Re: Gin index on array of uuid

Ok, I think this is close as you point out.

I can see the GIN (2742 pg_am oid - access method) op classes defined
explicitly for a lot of the core types in pg_opclass.h.

I can also see various GIN operator functions defined in pg_proc ("select
proname, proargtypes from pg_proc where proname like '%extract%' " and
many comparison functions "select proname, proargtypes from pg_proc where
proname like '%cmp%' ").

It seems one way to do this is to add the missing remaining built in types
such as UUID to pg_opclass.h.... but I am missing how this
"DATA(insert(...))" operator class definition links to the four GIN
functions (&&, @>, <@ and =). Is there a separate table or definition
responsible for this linking?

Taking _timestamp_ops as an example:
DATA(insert ( 2742 _timestamp_ops PGNSP PGUID 2745 1115 t 1114 ));
How does postgresql determine the GIN function bindings? Where does this
function pointer resolution occur?

Thank you,
Enrique

[image: pasted2]

[image: pasted3]

[image: pasted1]

On Tue, Jun 21, 2016 at 12:20 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

Show quoted text

Enrique MailingLists <enrique.mailing.lists@gmail.com> writes:

Currently creating an index on an array of UUID involves defining an
operator class. I was wondering if this would be a valid request to add

as

part of the uuid-ossp extension? This seems like a reasonable operator to
support as a default for UUIDs.

This makes me itch, really, because if we do this then we should logically
do it for every other add-on type.

It seems like we are not that far from being able to have just one GIN
opclass on "anyarray". The only parts of this declaration that are
UUID-specific are the comparator function and the storage type, both of
which could be gotten without that much trouble, one would think.

Any downsides to adding this as a default?

Well, it'd likely break things at dump/reload time for people who had
already created a competing "default for _uuid" opclass manually. I'm not
entirely sure, but possibly replacing the core opclasses with a single one
that is "default for anyarray" could avoid such failures. We'd have to
figure out ambiguity resolution rules.

regards, tom lane

Attachments:

pasted1image/png; name=pasted1Download
pasted2image/png; name=pasted2Download+9-1
pasted3image/png; name=pasted3Download+4-5