public inbox for [email protected]  
help / color / mirror / Atom feed
Request for new column in pg_namespace
4+ messages / 3 participants
[nested] [flat]

* Request for new column in pg_namespace
@ 2024-12-15 16:58  Ron Johnson <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Ron Johnson @ 2024-12-15 16:58 UTC (permalink / raw)
  To: pgsql-general

https://www.postgresql.org/docs/current/catalog-pg-namespace.html

Currently, when I want to query all "userland" tables, I write something
like:
select ...
from pg_class cl, pg_namespace nsp
where cl.relnamespace = nsp.oid
  and nsp.nspname not like 'pg_%
  and nsp.nspname != 'information_schema';

A new boolean column named "indissystem" that's true only for system
relations would make *many* maintenance queries cleaner, since they'd look
like:
select ...
from pg_class cl, pg_namespace nsp
where cl.relnamespace = nsp.oid
  and nsp.indissystem = false;

-- 
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Request for new column in pg_namespace
@ 2024-12-15 17:15  Pavel Stehule <[email protected]>
  parent: Ron Johnson <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Pavel Stehule @ 2024-12-15 17:15 UTC (permalink / raw)
  To: Ron Johnson <[email protected]>; +Cc: pgsql-general

Hi

ne 15. 12. 2024 v 17:59 odesílatel Ron Johnson <[email protected]>
napsal:

> https://www.postgresql.org/docs/current/catalog-pg-namespace.html
>
> Currently, when I want to query all "userland" tables, I write something
> like:
> select ...
> from pg_class cl, pg_namespace nsp
> where cl.relnamespace = nsp.oid
>   and nsp.nspname not like 'pg_%
>   and nsp.nspname != 'information_schema';
>
> A new boolean column named "indissystem" that's true only for system
> relations would make *many* maintenance queries cleaner, since they'd
> look like:
> select ...
> from pg_class cl, pg_namespace nsp
> where cl.relnamespace = nsp.oid
>   and nsp.indissystem = false;
>
>
oid of all system objects is less then 0x4000

Regards

Pavel



> --
> Death to <Redacted>, and butter sauce.
> Don't boil me, I'm still alive.
> <Redacted> lobster!
>


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Request for new column in pg_namespace
@ 2024-12-15 17:29  Tom Lane <[email protected]>
  parent: Pavel Stehule <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2024-12-15 17:29 UTC (permalink / raw)
  To: Pavel Stehule <[email protected]>; +Cc: Ron Johnson <[email protected]>; pgsql-general

Pavel Stehule <[email protected]> writes:
> ne 15. 12. 2024 v 17:59 odesílatel Ron Johnson <[email protected]>
> napsal:
>> A new boolean column named "indissystem" that's true only for system
>> relations would make *many* maintenance queries cleaner, since they'd
>> look like:
>> select ...

> oid of all system objects is less then 0x4000

That wouldn't help for excluding temp schemas, and it's not totally
trustworthy for information_schema either.

But I think the real problem with Ron's proposal is that it presumes
there is a one-size-fits-all notion of "system schema".  As a
counterexample, for some maintenance activities (such as vacuuming)
you might wish to process pg_catalog.

What I'd suggest as an improvement that could be implemented
immediately is to wrap the checks in a user-defined function
like "is_system_schema(nspname name)".

			regards, tom lane






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Request for new column in pg_namespace
@ 2024-12-15 17:46  Ron Johnson <[email protected]>
  parent: Tom Lane <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: Ron Johnson @ 2024-12-15 17:46 UTC (permalink / raw)
  To: pgsql-general

On Sun, Dec 15, 2024 at 12:29 PM Tom Lane <[email protected]> wrote:

> Pavel Stehule <[email protected]> writes:
> > ne 15. 12. 2024 v 17:59 odesílatel Ron Johnson <[email protected]>
> > napsal:
> >> A new boolean column named "indissystem" that's true only for system
> >> relations would make *many* maintenance queries cleaner, since they'd
> >> look like:
> >> select ...
>
> > oid of all system objects is less then 0x4000
>
> That wouldn't help for excluding temp schemas, and it's not totally
> trustworthy for information_schema either.
>
> But I think the real problem with Ron's proposal is that it presumes
> there is a one-size-fits-all notion of "system schema".  As a
> counterexample, for some maintenance activities (such as vacuuming)
> you might wish to process pg_catalog.
>

In that case, one would explicitly mention pg_catalog, no?
where cl.relnamespace = nsp.oid
  and (nsp.indissystem = false or nsp.nspname = 'pg_catalog');


> What I'd suggest as an improvement that could be implemented
> immediately is to wrap the checks in a user-defined function
> like "is_system_schema(nspname name)".
>

Good idea.

-- 
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!


^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2024-12-15 17:46 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-12-15 16:58 Request for new column in pg_namespace Ron Johnson <[email protected]>
2024-12-15 17:15 ` Pavel Stehule <[email protected]>
2024-12-15 17:29   ` Tom Lane <[email protected]>
2024-12-15 17:46     ` Ron Johnson <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox