Using FOREIGN TABLE to get the Size of the Actual Remote Table Behind it

Started by Avi Weinbergabout 4 years ago2 messagesgeneral
Jump to latest
#1Avi Weinberg
AviW@gilat.com

Hi Experts,

Is it possible to get the size of the table a foreign table is pointing to (without creating another connecting to the remote server)? Obviously this "select pg_size_pretty(pg_total_relation_size('f_table'))" returns 0.

Thanks!

IMPORTANT - This email and any attachments is intended for the above named addressee(s), and may contain information which is confidential or privileged. If you are not the intended recipient, please inform the sender immediately and delete this email: you should not copy or use this e-mail for any purpose nor disclose its contents to any person.

#2Laurenz Albe
laurenz.albe@cybertec.at
In reply to: Avi Weinberg (#1)
Re: Using FOREIGN TABLE to get the Size of the Actual Remote Table Behind it

On Thu, 2022-01-13 at 09:49 +0000, Avi Weinberg wrote:

Is it possible to get the size of the table a foreign table is pointing to (without creating
another connecting to the remote server)?  Obviously this "select
pg_size_pretty(pg_total_relation_size('f_table'))" returns 0.

No, there is no straightforward way to do that.

What you could do is create a view on the remote database that provides the
required information and access that view via a foreign table.

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com