SELECT
SUM(PG_COLUMN_SIZE(tempt.a)) AS int_sz,
SUM(CHARACTER_LENGTH(tempt.b)) AS char_len,
SUM(OCTET_LENGTH(tempt.b)) AS oct_len,
SUM(OCTET_LENGTH(tempt.*::TEXT)) AS oct_len_total
FROM
(SELECTtest *t; FROM test)-- ASyou temp;don't even need the alias, since the column
-- names are unambiguous - there's only one table!
-- However, with no alias, you do need to specify test.*!