pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedNew operators and class for jsonb with gin indexing
4+ messages / 2 participants
[nested] [flat]
* New operators and class for jsonb with gin indexing
@ 2021-02-23 14:30 Luka Zivkovic <lukazivkovic58@gmail.com>
2021-02-23 15:28 ` Re: New operators and class for jsonb with gin indexing Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Luka Zivkovic @ 2021-02-23 14:30 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hello all!
I am having problems applying gin indexing to my new operator class for
type jsonb.
I created an operator that can query(jsonb column) keys and dates where
dates are more than, less than, equal and not equal to the one provided
inside another jsonb.
Because I want to make it use index search and not sequential search, I
wanted to use gin indexing, but it says that i'm missing support functions.
Did anybody try to do something like this? I searched everywhere online,
and I didn't see an example of how they should look like. This is how i
created an operator class
CREATE OPERATOR CLASS custom_jsonb_dates_operators FOR TYPE jsonb
USING gin AS
OPERATOR 1 #>? (jsonb, jsonb),
OPERATOR 2 #<? (jsonb, jsonb),
OPERATOR 3 #=? (jsonb, jsonb),
OPERATOR 4 #!=? (jsonb, jsonb)
After this, when i created an index with this operator class, i got the
following error:
missing support function 2 for attribute 1 of index "idx_name"
I tried writing my own support functions, but none worked(after creating an
index, it just never returned any results.
Thanks,
Luka Zivkovic
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: New operators and class for jsonb with gin indexing
2021-02-23 14:30 New operators and class for jsonb with gin indexing Luka Zivkovic <lukazivkovic58@gmail.com>
@ 2021-02-23 15:28 ` Tom Lane <tgl@sss.pgh.pa.us>
2021-02-23 15:40 ` Re: New operators and class for jsonb with gin indexing Luka Zivkovic <lukazivkovic58@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Tom Lane @ 2021-02-23 15:28 UTC (permalink / raw)
To: Luka Zivkovic <lukazivkovic58@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
Luka Zivkovic <lukazivkovic58@gmail.com> writes:
> I am having problems applying gin indexing to my new operator class for
> type jsonb.
> I created an operator that can query(jsonb column) keys and dates where
> dates are more than, less than, equal and not equal to the one provided
> inside another jsonb.
> Because I want to make it use index search and not sequential search, I
> wanted to use gin indexing, but it says that i'm missing support functions.
> Did anybody try to do something like this?
There's not a whole lot of documentation about this, but there is some:
https://www.postgresql.org/docs/13/gin-extensibility.html
After reading that, I'd suggest looking into the code for gin opclass
support in various contrib modules (hstore might be a good start).
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: New operators and class for jsonb with gin indexing
2021-02-23 14:30 New operators and class for jsonb with gin indexing Luka Zivkovic <lukazivkovic58@gmail.com>
2021-02-23 15:28 ` Re: New operators and class for jsonb with gin indexing Tom Lane <tgl@sss.pgh.pa.us>
@ 2021-02-23 15:40 ` Luka Zivkovic <lukazivkovic58@gmail.com>
2021-02-23 15:53 ` Re: New operators and class for jsonb with gin indexing Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Luka Zivkovic @ 2021-02-23 15:40 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general@lists.postgresql.org
Thank you for your response!
Yeah, i was looking i to that, and it looks like i just didn't implement
it correctly. I'm just wondering because I'm using it for jsonb type, can i
just use already implemented support functions for jsonb? I'm just not too
sure how those functions work
Thanks,
Luka Živković
On Tue, Feb 23, 2021, 16:28 Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Luka Zivkovic <lukazivkovic58@gmail.com> writes:
> > I am having problems applying gin indexing to my new operator class for
> > type jsonb.
> > I created an operator that can query(jsonb column) keys and dates where
> > dates are more than, less than, equal and not equal to the one provided
> > inside another jsonb.
> > Because I want to make it use index search and not sequential search, I
> > wanted to use gin indexing, but it says that i'm missing support
> functions.
> > Did anybody try to do something like this?
>
> There's not a whole lot of documentation about this, but there is some:
>
> https://www.postgresql.org/docs/13/gin-extensibility.html
>
> After reading that, I'd suggest looking into the code for gin opclass
> support in various contrib modules (hstore might be a good start).
>
> regards, tom lane
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: New operators and class for jsonb with gin indexing
2021-02-23 14:30 New operators and class for jsonb with gin indexing Luka Zivkovic <lukazivkovic58@gmail.com>
2021-02-23 15:28 ` Re: New operators and class for jsonb with gin indexing Tom Lane <tgl@sss.pgh.pa.us>
2021-02-23 15:40 ` Re: New operators and class for jsonb with gin indexing Luka Zivkovic <lukazivkovic58@gmail.com>
@ 2021-02-23 15:53 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 4+ messages in thread
From: Tom Lane @ 2021-02-23 15:53 UTC (permalink / raw)
To: Luka Zivkovic <lukazivkovic58@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
Luka Zivkovic <lukazivkovic58@gmail.com> writes:
> Yeah, i was looking i to that, and it looks like i just didn't implement
> it correctly. I'm just wondering because I'm using it for jsonb type, can i
> just use already implemented support functions for jsonb? I'm just not too
> sure how those functions work
The support functions need to know about the operators' semantics, so
you have to write your own when inventing new operators.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2021-02-23 15:53 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-02-23 14:30 New operators and class for jsonb with gin indexing Luka Zivkovic <lukazivkovic58@gmail.com>
2021-02-23 15:28 ` Tom Lane <tgl@sss.pgh.pa.us>
2021-02-23 15:40 ` Luka Zivkovic <lukazivkovic58@gmail.com>
2021-02-23 15:53 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox