Skip site navigation (1) Skip section navigation (2)

About inheritance

From: Ioannis Theoharis <theohari(at)ics(dot)forth(dot)gr>
To: pgsql-general(at)postgresql(dot)org
Subject: About inheritance
Date: 2004-08-22 16:13:00
Message-ID: Pine.GSO.4.58.0408221859360.19115@calliope (view raw or flat)
Thread:
Lists: pgsql-general

Hi,

i have 3 tables calling father, child1, child2:

create table father(att0 int4);
create table child1() inherits(father);
create table child2() inherits(father);


i want to get all the instances of the hierarchy:
select * from father;

the explain analyze gives:

 Result
   ->  Append
         ->  Seq Scan on father
         ->  Seq Scan on child1 father



Now i drop the tables and i create them aggain without using the inherits
relationship:

create table father(att0 int4);
create table child1(att0 int4);
create table child2(att0 int4);

again i want to get all the instances of the hierarchy:
(select * from father) UNION ALL (select * from child1) UNION ALL
(select * from child2);

the explain analyze gives:

 Append
   ->  Subquery Scan "*SELECT* 1"
         ->  Seq Scan on father
   ->  Subquery Scan "*SELECT* 2"
         ->  Seq Scan on child1
   ->  Subquery Scan "*SELECT* 3"
         ->  Seq Scan on child2


Can anyone explain me the difference between these two plans?

I expekt to find the same plans because in both cases there is a union to
be done, but i see that in second case there is an additional call to a
routine. I meen the 'Subquery Scan "*SELECT* X"'

Responses

pgsql-general by date

Next:From: Mike NolanDate: 2004-08-22 16:25:55
Subject: Re: Unsupported 3rd-party solutions (Was: Few questions on postgresql (dblink, 2pc, clustering)) (fwd)
Previous:From: Thomas HallgrenDate: 2004-08-22 14:14:44
Subject: Re: Unsupported 3rd-party solutions (Was: Few questions on postgresql

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group