Re: [HACKERS] Table size does not include toast size

2010-01-18 Thread Tom Lane
Bernd Helmle writes: > Since i'm not able to finish those other things in time, i wrapped up my > existing code for this issue and came up with the attached patch, which > should implement the behavior Tom proposed. These are two new functions > pg_table_size() and pg_indexes_size(). This patch

Re: [HACKERS] Table size does not include toast size

2010-01-18 Thread Greg Smith
Tom Lane wrote: I'm inclined to think that table vs. index is the right level of abstraction for these functions, and that breaking it down further than that isn't all that helpful. We have the bottom-level information (per-fork relation size) available for those who really want the details.

Re: [HACKERS] Table size does not include toast size

2010-01-18 Thread Tom Lane
Greg Smith writes: > The only question I'm left with after browsing the patch and staring at > the above results is whether it makes sense to expose a pg_toast_size > function. That would make the set available here capable of handling > almost every situation somebody might want to know about

Re: [HACKERS] Table size does not include toast size

2010-01-18 Thread Greg Smith
Bernd Helmle wrote: These are two new functions pg_table_size() and pg_indexes_size(). This patch also changes pg_total_relation_size() to be a shorthand for pg_table_size() + pg_indexes_size(). Attached is a test program to exercise these new functions. I thoroughly abuse generate_series an

Re: [HACKERS] Table size does not include toast size

2010-01-14 Thread Bernd Helmle
--On 22. Dezember 2009 15:11:40 +0100 Bernd Helmle wrote: Bernd, there's a basic spec if you have time to work on this. I see if i can get some time for it during christmas vacation (its on my radar for a longer period of time). I'm still working on this NOT NULL pg_constraint representat

Re: [HACKERS] Table size does not include toast size

2009-12-22 Thread Tom Lane
=?ISO-8859-1?Q?C=E9dric_Villemain?= writes: > 2009/12/21 Tom Lane : >> Perhaps invent  pg_table_size() = base table + toast table + toast index >> and             pg_indexes_size() = all other indexes for table >> giving us the property pg_table_size + pg_indexes_size = >> pg_total_relation_size

Re: [HACKERS] Table size does not include toast size

2009-12-22 Thread Bernd Helmle
--On 21. Dezember 2009 12:02:02 -0500 Greg Smith wrote: Tom Lane wrote: Perhaps invent pg_table_size() = base table + toast table + toast index and pg_indexes_size() = all other indexes for table giving us the property pg_table_size + pg_indexes_size = pg_total_relation_size

Re: [HACKERS] Table size does not include toast size

2009-12-22 Thread Bernd Helmle
--On 22. Dezember 2009 11:46:32 +0100 Cédric Villemain wrote: Did you mean : pg_table_size() = base table + toast table pg_indexes_size() = base indexes + toast indexes ? Since you always have a toast index automatically it makes sense to include them in pg_table_size(). -- Thanks

Re: [HACKERS] Table size does not include toast size

2009-12-22 Thread Cédric Villemain
2009/12/21 Tom Lane : > Greg Smith writes: >> To answer Rafael's concerns directly:  you're right that this is >> confusing.  pg_relation_size is always going to do what it does right >> now just because of how that fits into the design of the database. >> However, the documentation should be upda

Re: [HACKERS] Table size does not include toast size

2009-12-21 Thread Tom Lane
Greg Stark writes: > On Mon, Dec 21, 2009 at 5:02 PM, Greg Smith wrote: >> Right; that's exactly the way I'm computing things now, I just have to crawl >> way too much catalog data to do it.  I also agree that if we provide >> pg_table_size, the issue of "pg_relation_size doesn't do what I want"

Re: [HACKERS] Table size does not include toast size

2009-12-21 Thread Greg Stark
On Mon, Dec 21, 2009 at 5:02 PM, Greg Smith wrote: > Tom Lane wrote: >> >> Perhaps invent  pg_table_size() = base table + toast table + toast index >> and             pg_indexes_size() = all other indexes for table >> giving us the property pg_table_size + pg_indexes_size = >> pg_total_relation_si

Re: [HACKERS] Table size does not include toast size

2009-12-21 Thread Greg Smith
Tom Lane wrote: Perhaps invent pg_table_size() = base table + toast table + toast index and pg_indexes_size() = all other indexes for table giving us the property pg_table_size + pg_indexes_size = pg_total_relation_size Right; that's exactly the way I'm computing things now, I jus

Re: [HACKERS] Table size does not include toast size

2009-12-21 Thread Tom Lane
Greg Smith writes: > To answer Rafael's concerns directly: you're right that this is > confusing. pg_relation_size is always going to do what it does right > now just because of how that fits into the design of the database. > However, the documentation should be updated to warn against the

Re: [HACKERS] Table size does not include toast size

2009-12-21 Thread Greg Smith
Bernd Helmle wrote: I've created a C-Function a while ago that extracts the TOAST size for a given relation. This gave me the opportunity to do a pg_relation_size(oid) + pg_relation_toast_size(oid) for a given table oid to calculate on disk data size required by a table. Maybe we should includ

Re: [HACKERS] Table size does not include toast size

2009-12-21 Thread Rafael Martinez
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Tom Lane wrote: > Rafael Martinez writes: >> I am probably missing the point here, why is it not supposed to show the >> size of the table(data) *without* indexes? > > Because pg_relation_size is defined at the "physical" level of showing > one relat

Re: [HACKERS] Table size does not include toast size

2009-12-21 Thread Rafael Martinez
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Bernd Helmle wrote: > > > --On 21. Dezember 2009 10:01:37 -0500 Tom Lane wrote: > >> It's not supposed to. Use pg_total_relation_size if you want a number >> that includes index and toast space. > > I've created a C-Function a while ago that extr

Re: [HACKERS] Table size does not include toast size

2009-12-21 Thread Tom Lane
Rafael Martinez writes: > I am probably missing the point here, why is it not supposed to show the > size of the table(data) *without* indexes? Because pg_relation_size is defined at the "physical" level of showing one relation, where relation means a pg_class entry. If you want agglomerations o

Re: [HACKERS] Table size does not include toast size

2009-12-21 Thread Bernd Helmle
--On 21. Dezember 2009 10:01:37 -0500 Tom Lane wrote: It's not supposed to. Use pg_total_relation_size if you want a number that includes index and toast space. I've created a C-Function a while ago that extracts the TOAST size for a given relation. This gave me the opportunity to do a pg

Re: [HACKERS] Table size does not include toast size

2009-12-21 Thread Rafael Martinez
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Tom Lane wrote: > Rafael Martinez writes: >> I wonder why the function pg_relation_size(text) does not take into >> account the space used by toast data in a table when returning the space >> used by the table. > > It's not supposed to. Use pg_total

Re: [HACKERS] Table size does not include toast size

2009-12-21 Thread Tom Lane
Rafael Martinez writes: > I wonder why the function pg_relation_size(text) does not take into > account the space used by toast data in a table when returning the space > used by the table. It's not supposed to. Use pg_total_relation_size if you want a number that includes index and toast space.

[HACKERS] Table size does not include toast size

2009-12-21 Thread Rafael Martinez
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello I wonder why the function pg_relation_size(text) does not take into account the space used by toast data in a table when returning the space used by the table. As an administrator I would expect pg_total_relation_size() to return data+toast+ind