From: | Ryan Murphy <ryanfmurphy(at)gmail(dot)com> |
---|---|
To: | David Rowley <david(dot)rowley(at)2ndquadrant(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Is there a way to create a functional index that tables tableoid column as an arg? |
Date: | 2018-03-13 20:05:46 |
Message-ID: | CAHeEsBeCchYGrMbZ=f07jMPO6t=WZRY7dvQhgLCTBwOMB0KXXg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi David! Thanks for the reply.
> tableoid might be an exception to
> this, but it does not really seem like a useful column to index,
> giving it would be indexing the same value for each record in the
> table.
Unless you're using inheritance - then tableoid may vary. That's the case
I'm interested in.
> -- get all animals that are persons
> select ... from animal where tableoid in (select
> get_inherited_tables('person'::regclass);
>
> -- get all animals that are not persons
> select ... from animal where tableoid not in (select
> get_inherited_tables('person'::regclass);
>
>
That's a great idea. I'll try it!
> Just be careful around search_paths and your use of regclass. In this
> case, if "animal" was not in the first schema in search_path, but
> someone created another table called "person" that was in the first
> schema listed in search_path, then the query would not do what you
> want. You might want to consider prefixing the input parameter into
> get_inherited_tables with the schema name too.
>
Good point.
Thanks again!
Ryan
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2018-03-13 20:52:16 | Re: Is there a way to create a functional index that tables tableoid column as an arg? |
Previous Message | Thomas Kellerer | 2018-03-13 19:21:47 | Re: query_to_xml() returns invalid XML when query returns no rows |