pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedselect results on pg_class incomplete
12+ messages / 6 participants
[nested] [flat]
* select results on pg_class incomplete
@ 2024-03-14 16:41 Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-14 17:01 ` Re: select results on pg_class incomplete Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 1 reply; 12+ messages in thread
From: Thiemo Kellner @ 2024-03-14 16:41 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hi
I am trying to access PostgreSQL meta data, possibly in a vane attempt
to get size data.
I use DbVis with a connection as shown in https://ibb.co/2SDzhXt . I try
to get information on a regular table "umsaetze". When doing the DbVis
object I can see them - https://ibb.co/WxMnY2c . If I execute following
SQL query in DbVis's SQL Commander, the result set is empty -
https://ibb.co/GngdWLH .
select *
from PG_CLASS
where RELNAME = 'umsaetze';
I noticed that the sessions producing the different results are not the
same - https://ibb.co/wdKcCFc , but seem to connect to different
databases. The "missing" table is indeed in the budget database.
The connection user is, apart from being member of pg_monitor vanilla -
https://ibb.co/DGs6sQz and https://ibb.co/8xzHrvP .
It seems, that in pg_class only is, with respect to custom databases,
listed what is in the database one connects to - https://ibb.co/dbbJVbJ.
template1=> select count(*)
from PG_CLASS
where RELNAME = 'umsaetze';
count
-------
0
(1 row)
template1=> \q
C:\Users\thiemo\AppData\Roaming\MOBAXT~1\home>psql -h hp-slimline-260 -p
5436 -U monitor budget
psql (11.2, server 16.1 (Debian 16.1-1.pgdg110+1))
WARNING: psql major version 11, server major version 16.
Some psql features might not work.
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384,
bits: 256, compression: off)
Type "help" for help.
budget=> select count(*)
from PG_CLASS
where RELNAME = 'umsaetze';
count
-------
2
(1 row)
budget=> \q
Is there a possibility to make the user monitor see all the objects of
the cluster? Background is that I was hoping to create a query to spit
out the size of tables in the cluster.
Kind regards
Thiemo
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: select results on pg_class incomplete
2024-03-14 16:41 select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
@ 2024-03-14 17:01 ` Adrian Klaver <adrian.klaver@aklaver.com>
2024-03-14 18:08 ` Re: select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
0 siblings, 1 reply; 12+ messages in thread
From: Adrian Klaver @ 2024-03-14 17:01 UTC (permalink / raw)
To: Thiemo Kellner <thiemo@gelassene-pferde.biz>; pgsql-general@lists.postgresql.org
On 3/14/24 09:41, Thiemo Kellner wrote:
> Hi
>
> I am trying to access PostgreSQL meta data, possibly in a vane attempt
> to get size data.
>
> I use DbVis with a connection as shown in https://ibb.co/2SDzhXt . I try
> to get information on a regular table "umsaetze". When doing the DbVis
> object I can see them - https://ibb.co/WxMnY2c . If I execute following
> SQL query in DbVis's SQL Commander, the result set is empty -
> https://ibb.co/GngdWLH .
>
> select *
> from PG_CLASS
> where RELNAME = 'umsaetze';
>
> I noticed that the sessions producing the different results are not the
> same - https://ibb.co/wdKcCFc , but seem to connect to different
> databases. The "missing" table is indeed in the budget database.
>
> The connection user is, apart from being member of pg_monitor vanilla -
> https://ibb.co/DGs6sQz and https://ibb.co/8xzHrvP .
>
> It seems, that in pg_class only is, with respect to custom databases,
> listed what is in the database one connects to - https://ibb.co/dbbJVbJ.
As listed on the tin:
https://www.postgresql.org/docs/current/catalogs-overview.html
"Most system catalogs are copied from the template database during
database creation and are thereafter database-specific. A few catalogs
are physically shared across all databases in a cluster; these are noted
in the descriptions of the individual catalogs."
pg_class is not one of the global tables.
>
> template1=> select count(*)
> from PG_CLASS
> where RELNAME = 'umsaetze';
> count
> -------
> 0
> (1 row)
>
> template1=> \q
>
> C:\Users\thiemo\AppData\Roaming\MOBAXT~1\home>psql -h hp-slimline-260 -p
> 5436 -U monitor budget
> psql (11.2, server 16.1 (Debian 16.1-1.pgdg110+1))
> WARNING: psql major version 11, server major version 16.
> Some psql features might not work.
> SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384,
> bits: 256, compression: off)
> Type "help" for help.
>
> budget=> select count(*)
> from PG_CLASS
> where RELNAME = 'umsaetze';
> count
> -------
> 2
> (1 row)
>
> budget=> \q
>
>
> Is there a possibility to make the user monitor see all the objects of
> the cluster? Background is that I was hoping to create a query to spit
> out the size of tables in the cluster.
>
> Kind regards
>
> Thiemo
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: select results on pg_class incomplete
2024-03-14 16:41 select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-14 17:01 ` Re: select results on pg_class incomplete Adrian Klaver <adrian.klaver@aklaver.com>
@ 2024-03-14 18:08 ` Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-14 18:12 ` Re: select results on pg_class incomplete David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 1 reply; 12+ messages in thread
From: Thiemo Kellner @ 2024-03-14 18:08 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general@lists.postgresql.org
Thanks for the enlightenment. A pity. I suppose, there is no working
around this?
Am 14.03.2024 um 18:01 schrieb Adrian Klaver:
> On 3/14/24 09:41, Thiemo Kellner wrote:
>> Hi
>>
>> I am trying to access PostgreSQL meta data, possibly in a vane attempt
>> to get size data.
>>
>> I use DbVis with a connection as shown in https://ibb.co/2SDzhXt . I
>> try to get information on a regular table "umsaetze". When doing the
>> DbVis object I can see them - https://ibb.co/WxMnY2c . If I execute
>> following SQL query in DbVis's SQL Commander, the result set is empty
>> - https://ibb.co/GngdWLH .
>>
>> select *
>> from PG_CLASS
>> where RELNAME = 'umsaetze';
>>
>> I noticed that the sessions producing the different results are not
>> the same - https://ibb.co/wdKcCFc , but seem to connect to different
>> databases. The "missing" table is indeed in the budget database.
>>
>> The connection user is, apart from being member of pg_monitor vanilla
>> - https://ibb.co/DGs6sQz and https://ibb.co/8xzHrvP .
>>
>> It seems, that in pg_class only is, with respect to custom databases,
>> listed what is in the database one connects to - https://ibb.co/dbbJVbJ.
>
> As listed on the tin:
>
> https://www.postgresql.org/docs/current/catalogs-overview.html
>
> "Most system catalogs are copied from the template database during
> database creation and are thereafter database-specific. A few catalogs
> are physically shared across all databases in a cluster; these are noted
> in the descriptions of the individual catalogs."
>
> pg_class is not one of the global tables.
>
>>
>> template1=> select count(*)
>> from PG_CLASS
>> where RELNAME = 'umsaetze';
>> count
>> -------
>> 0
>> (1 row)
>>
>> template1=> \q
>>
>> C:\Users\thiemo\AppData\Roaming\MOBAXT~1\home>psql -h hp-slimline-260
>> -p 5436 -U monitor budget
>> psql (11.2, server 16.1 (Debian 16.1-1.pgdg110+1))
>> WARNING: psql major version 11, server major version 16.
>> Some psql features might not work.
>> SSL connection (protocol: TLSv1.2, cipher:
>> ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
>> Type "help" for help.
>>
>> budget=> select count(*)
>> from PG_CLASS
>> where RELNAME = 'umsaetze';
>> count
>> -------
>> 2
>> (1 row)
>>
>> budget=> \q
>>
>>
>> Is there a possibility to make the user monitor see all the objects of
>> the cluster? Background is that I was hoping to create a query to spit
>> out the size of tables in the cluster.
>>
>> Kind regards
>>
>> Thiemo
>>
>>
>
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: select results on pg_class incomplete
2024-03-14 16:41 select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-14 17:01 ` Re: select results on pg_class incomplete Adrian Klaver <adrian.klaver@aklaver.com>
2024-03-14 18:08 ` Re: select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
@ 2024-03-14 18:12 ` David G. Johnston <david.g.johnston@gmail.com>
2024-03-14 20:03 ` Re: select results on pg_class incomplete David Rowley <dgrowleyml@gmail.com>
0 siblings, 1 reply; 12+ messages in thread
From: David G. Johnston @ 2024-03-14 18:12 UTC (permalink / raw)
To: Thiemo Kellner <thiemo@gelassene-pferde.biz>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general@lists.postgresql.org
On Thu, Mar 14, 2024, 11:08 Thiemo Kellner <thiemo@gelassene-pferde.biz>
wrote:
> Thanks for the enlightenment. A pity. I suppose, there is no working
> around this?
Write a script to do the query in a loop on all databases - that catalog is
global.
David J.
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: select results on pg_class incomplete
2024-03-14 16:41 select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-14 17:01 ` Re: select results on pg_class incomplete Adrian Klaver <adrian.klaver@aklaver.com>
2024-03-14 18:08 ` Re: select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-14 18:12 ` Re: select results on pg_class incomplete David G. Johnston <david.g.johnston@gmail.com>
@ 2024-03-14 20:03 ` David Rowley <dgrowleyml@gmail.com>
2024-03-15 10:30 ` Re: select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
0 siblings, 1 reply; 12+ messages in thread
From: David Rowley @ 2024-03-14 20:03 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: Thiemo Kellner <thiemo@gelassene-pferde.biz>; Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general@lists.postgresql.org
On Fri, 15 Mar 2024 at 07:13, David G. Johnston
<david.g.johnston@gmail.com> wrote:
> On Thu, Mar 14, 2024, 11:08 Thiemo Kellner <thiemo@gelassene-pferde.biz> wrote:
>>
>> Thanks for the enlightenment. A pity. I suppose, there is no working
>> around this?
>
> Write a script to do the query in a loop on all databases - that catalog is global.
Yeah, maybe dblink and a LATERAL join might be an easy way. Something like:
create extension dblink;
select d.datname,c.relname from pg_database d, lateral (select * from
dblink('dbname='||d.datname,$$select relname from pg_class where
relname = 'pg_class';$$) c(relname text)) c
(relname) where d.datallowconn;
datname | relname
------------+----------
postgres | pg_class
template1 | pg_class
regression | pg_class
(3 rows)
David
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: select results on pg_class incomplete
2024-03-14 16:41 select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-14 17:01 ` Re: select results on pg_class incomplete Adrian Klaver <adrian.klaver@aklaver.com>
2024-03-14 18:08 ` Re: select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-14 18:12 ` Re: select results on pg_class incomplete David G. Johnston <david.g.johnston@gmail.com>
2024-03-14 20:03 ` Re: select results on pg_class incomplete David Rowley <dgrowleyml@gmail.com>
@ 2024-03-15 10:30 ` Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-15 12:59 ` Re: select results on pg_class incomplete Christophe Pettus <xof@thebuild.com>
0 siblings, 1 reply; 12+ messages in thread
From: Thiemo Kellner @ 2024-03-15 10:30 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Am 14.03.2024 um 21:03 schrieb David Rowley:
> Yeah, maybe dblink and a LATERAL join might be an easy way. Something like:
>
> create extension dblink;
> select d.datname,c.relname from pg_database d, lateral (select * from
> dblink('dbname='||d.datname,$$select relname from pg_class where
> relname = 'pg_class';$$) c(relname text)) c
> (relname) where d.datallowconn;
> datname | relname
> ------------+----------
> postgres | pg_class
> template1 | pg_class
> regression | pg_class
> (3 rows)
Thanks for the ideas. As I would want to keep it in the database, dblink
would be the way to go. Maybe, I will create a prodedure that creates a
view in the monitor schema accessing the respective databases with union
all to concatenate the data.
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: select results on pg_class incomplete
2024-03-14 16:41 select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-14 17:01 ` Re: select results on pg_class incomplete Adrian Klaver <adrian.klaver@aklaver.com>
2024-03-14 18:08 ` Re: select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-14 18:12 ` Re: select results on pg_class incomplete David G. Johnston <david.g.johnston@gmail.com>
2024-03-14 20:03 ` Re: select results on pg_class incomplete David Rowley <dgrowleyml@gmail.com>
2024-03-15 10:30 ` Re: select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
@ 2024-03-15 12:59 ` Christophe Pettus <xof@thebuild.com>
2024-03-15 13:49 ` Re: select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
0 siblings, 1 reply; 12+ messages in thread
From: Christophe Pettus @ 2024-03-15 12:59 UTC (permalink / raw)
To: Thiemo Kellner <thiemo@gelassene-pferde.biz>; +Cc: pgsql-general@lists.postgresql.org
> On Mar 15, 2024, at 03:30, Thiemo Kellner <thiemo@gelassene-pferde.biz> wrote:
> Thanks for the ideas. As I would want to keep it in the database, dblink would be the way to go. Maybe, I will create a prodedure that creates a view in the monitor schema accessing the respective databases with union all to concatenate the data.
You could also create a PostgreSQL foreign server for each of the other databases, which would let you issue a query to UNION together the results of a query on all of the catalogs. This would require creating a foreign table for pg_class in the other databases.
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: select results on pg_class incomplete
2024-03-14 16:41 select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-14 17:01 ` Re: select results on pg_class incomplete Adrian Klaver <adrian.klaver@aklaver.com>
2024-03-14 18:08 ` Re: select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-14 18:12 ` Re: select results on pg_class incomplete David G. Johnston <david.g.johnston@gmail.com>
2024-03-14 20:03 ` Re: select results on pg_class incomplete David Rowley <dgrowleyml@gmail.com>
2024-03-15 10:30 ` Re: select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-15 12:59 ` Re: select results on pg_class incomplete Christophe Pettus <xof@thebuild.com>
@ 2024-03-15 13:49 ` Thiemo Kellner <thiemo@gelassene-pferde.biz>
0 siblings, 0 replies; 12+ messages in thread
From: Thiemo Kellner @ 2024-03-15 13:49 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
> You could also create a PostgreSQL foreign server for each of the other databases, which would let you issue a query to UNION together the results of a query on all of the catalogs. This would require creating a foreign table for pg_class in the other databases.
Thanks. So many possibilities. I am more familiar with dblinks than
foreign tables. I will read into it.
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: select results on pg_class incomplete
@ 2024-03-15 10:42 Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-15 13:46 ` Re: select results on pg_class incomplete Greg Sabino Mullane <htamfids@gmail.com>
2024-03-15 15:14 ` Re: select results on pg_class incomplete Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 2 replies; 12+ messages in thread
From: Thiemo Kellner @ 2024-03-15 10:42 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
> You solve a problem that no one has. Data belonging together may still be divided into schemas in a database. Thus, the metadata is also reported and archived individually per database.
I am not sure, we are taking about the same problem, but would be
surprised to be the only one having experienced filling disks. Maybe, I
am just that old already that disk space has become so cheep, the
problem does not exist any longer.
With respect to metadata and databases: The point is not that I cannot
see the tables in another schema (I believe, did not check yet), but in
other databases. While this actually does not matter much, I still hold
it true that a disk getting filled up does not care in which database or
schema a explosively growing table resides. So, if I have a disk getting
filled up, I would like to get easily information on the problematic
structures in one go. With PostgreSQL this does not seem to be possible
out of the box. I now can query each database separately, or I can
create auxiliary structures like dblink and views to accommodate for a
"single" query solution. My two dimes.
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: select results on pg_class incomplete
2024-03-15 10:42 Re: select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
@ 2024-03-15 13:46 ` Greg Sabino Mullane <htamfids@gmail.com>
2024-03-15 13:51 ` Re: select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
1 sibling, 1 reply; 12+ messages in thread
From: Greg Sabino Mullane @ 2024-03-15 13:46 UTC (permalink / raw)
To: Thiemo Kellner <thiemo@gelassene-pferde.biz>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
On Fri, Mar 15, 2024 at 6:43 AM Thiemo Kellner <thiemo@gelassene-pferde.biz>
wrote:
> I am not sure, we are taking about the same problem, but would be
> surprised to be the only one having experienced filling disks.
...
> So, if I have a disk getting filled up, I would like to get easily
> information on the problematic
> structures in one go.
This is a common problem, and one that has been solved before. There are
many monitoring solutions out there that can help you with this. For an
incomplete list, see:
https://wiki.postgresql.org/wiki/Monitoring
If you want to roll your own, the other thread is full of good information
on that.
Cheers,
Greg
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: select results on pg_class incomplete
2024-03-15 10:42 Re: select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-15 13:46 ` Re: select results on pg_class incomplete Greg Sabino Mullane <htamfids@gmail.com>
@ 2024-03-15 13:51 ` Thiemo Kellner <thiemo@gelassene-pferde.biz>
0 siblings, 0 replies; 12+ messages in thread
From: Thiemo Kellner @ 2024-03-15 13:51 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
> https://wiki.postgresql.org/wiki/Monitoring
Thanks for the URL. I am not too keen to re-invent the wheel. Although
it teaches me on PostgreSQL.
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: select results on pg_class incomplete
2024-03-15 10:42 Re: select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
@ 2024-03-15 15:14 ` Adrian Klaver <adrian.klaver@aklaver.com>
1 sibling, 0 replies; 12+ messages in thread
From: Adrian Klaver @ 2024-03-15 15:14 UTC (permalink / raw)
To: Thiemo Kellner <thiemo@gelassene-pferde.biz>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
On 3/15/24 03:42, Thiemo Kellner wrote:
>> You solve a problem that no one has. Data belonging together may still
>> be divided into schemas in a database. Thus, the metadata is also
>> reported and archived individually per database.
>
> I am not sure, we are taking about the same problem, but would be
> surprised to be the only one having experienced filling disks. Maybe, I
> am just that old already that disk space has become so cheep, the
> problem does not exist any longer.
>
> With respect to metadata and databases: The point is not that I cannot
> see the tables in another schema (I believe, did not check yet), but in
> other databases. While this actually does not matter much, I still hold
That is backwards, schemas are namespaces within a database you can see
their contents from the local(database) system catalogs.
> it true that a disk getting filled up does not care in which database or
> schema a explosively growing table resides. So, if I have a disk getting
> filled up, I would like to get easily information on the problematic
> structures in one go. With PostgreSQL this does not seem to be possible
> out of the box. I now can query each database separately, or I can
> create auxiliary structures like dblink and views to accommodate for a
> "single" query solution. My two dimes.
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 12+ messages in thread
end of thread, other threads:[~2024-03-15 15:14 UTC | newest]
Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-03-14 16:41 select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-14 17:01 ` Adrian Klaver <adrian.klaver@aklaver.com>
2024-03-14 18:08 ` Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-14 18:12 ` David G. Johnston <david.g.johnston@gmail.com>
2024-03-14 20:03 ` David Rowley <dgrowleyml@gmail.com>
2024-03-15 10:30 ` Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-15 12:59 ` Christophe Pettus <xof@thebuild.com>
2024-03-15 13:49 ` Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-15 10:42 Re: select results on pg_class incomplete Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-15 13:46 ` Greg Sabino Mullane <htamfids@gmail.com>
2024-03-15 13:51 ` Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-15 15:14 ` Adrian Klaver <adrian.klaver@aklaver.com>
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