Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hubmX-0000rt-NH for pgsql-general@arkaria.postgresql.org; Mon, 05 Aug 2019 12:08:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hubmW-0002Ms-BB for pgsql-general@arkaria.postgresql.org; Mon, 05 Aug 2019 12:08:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hubmW-0002Ml-1Y for pgsql-general@lists.postgresql.org; Mon, 05 Aug 2019 12:08:04 +0000 Received: from n3.nabble.com ([162.255.23.22]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hubmS-0005Ha-R4 for pgsql-general@postgresql.org; Mon, 05 Aug 2019 12:08:03 +0000 Received: from n3.nabble.com (localhost [127.0.0.1]) by n3.nabble.com (Postfix) with ESMTP id 507981611D4C7 for ; Mon, 5 Aug 2019 05:07:58 -0700 (MST) Date: Mon, 5 Aug 2019 05:07:58 -0700 (MST) From: PegoraroF10 To: pgsql-general@postgresql.org Message-ID: <1565006878327-0.post@n3.nabble.com> Subject: why toasted is created when domain is used ? MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk select count(*) Total_Tables, count(*) filter (where t2.oid is not null) Toasted_Tables, count(*) filter (where t2.reltuples > 0) Toasted_with_records from pg_class t1 left join pg_class t2 on t1.reltoastrelid =3D t2.oid and t2.relkind =3D 't' where t1.relkind =3D 'r' total_tables=09toasted_tables=09toasted_with_records 11564=09 9521=09 263 Then seeing structure of my tables only few of them really needs toasting, so it=C2=B4s ok to have few toast tables with records. The question is, why= those toasted tables were created ? Then, doing a simple test using one of those tables ... create table with_toast( id_pk i32, Field2 i32 not null, Field3 i16 not null, Field4 numeric(7, 2), Field5 i32 default public.DefaultValueForField(), Field6 datahora default CURRENT_TIMESTAMP); create table without_toast( id_pk integer, Field2 integer not null, Field3 smallint not null, Field4 numeric(7, 2), Field5 integer default public.DefaultValueForField(), Field6 timestamp default CURRENT_TIMESTAMP); As you can see this table doesn=C2=B4t need to have a toast and probably wi= ll never have records on it. select t1.oid, t1.relname, t1.relkind, t1.oid, t2.oid, t2.relname from pg_class t1 left join pg_class t2 on t1.reltoastrelid =3D t2.oid and t2.relkind =3D 't' inner join pg_namespace ns on ns.oid =3D t1.relnamespace where t1.relkind = =3D 'r' and t1.relname ~* 'test'; oid=09 relname=09 relkind=09oid=09 oid=09 relnam= e 9375155=09with_toast r=09 9375155=099375160=09pg_toast_937515= 5 9375167=09without_toast r=09 9375167=09NULL=09 NULL So, the question is, when I create a table using domains it creates a toast for it, why ? -- Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.h= tml