473,799 Members | 2,711 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

About inheritance



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"'

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #1
6 1266
Ioannis Theoharis <th******@ics.f orth.gr> writes:
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"'


The subquery scan step is in there because in a UNION construct, there
may be a need to do transformations on the data before it can be
unioned. For instance you are allowed to UNION an int4 and an int8
column, in which case the int4 values have to be promoted to int8 after
they come out of the subplan.

In the particular case you are showing, the subquery scan steps aren't
really doing anything, but AFAIR the planner does not bother to optimize
them out. I'd be pretty surprised if they chew up any meaningful amount
of runtime.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #2


Thanks.

Time is little but visible affected for big chierarhies.
Let me do an other question.

I have again a Root table and a hierarchie of tables, all created with the
inherits relationship like:

create table father(att0 int4);
create table child1() inherits(father );
create table child2() inherits(father );
create table child11() inherits(child1 );
create table child12() inherits(child1 );
create table child21() inherits(child2 );
create table child22() inherits(child2 );

First i insert 1000 tuples into father table, and then i delete them and i
insert them into child22

I expekt explain analyze to give the same response time at both cases. But
i found that time increases as where as the level, where data are located,
increases.

Can anybody explain me the reason?

On Sun, 22 Aug 2004, Tom Lane wrote:
Ioannis Theoharis <th******@ics.f orth.gr> writes:
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"'


The subquery scan step is in there because in a UNION construct, there
may be a need to do transformations on the data before it can be
unioned. For instance you are allowed to UNION an int4 and an int8
column, in which case the int4 values have to be promoted to int8 after
they come out of the subplan.

In the particular case you are showing, the subquery scan steps aren't
really doing anything, but AFAIR the planner does not bother to optimize
them out. I'd be pretty surprised if they chew up any meaningful amount
of runtime.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #3
Ioannis Theoharis <th******@ics.f orth.gr> writes:
I expekt explain analyze to give the same response time at both cases. But
i found that time increases as where as the level, where data are located,
increases.


I see no such effect.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 23 '05 #4


I'd like to ask you,
if postgres prefetch child instances in memory ,
whenever a parent table is sequentially scanned,
in order to have them in there
for the possibility the next query to ask for them.
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #5
On Sat, 2004-09-18 at 07:42, Ioannis Theoharis wrote:
I'd like to ask you,
if postgres prefetch child instances in memory ,
whenever a parent table is sequentially scanned,
in order to have them in there
for the possibility the next query to ask for them.


I'm not sure exactly what you're asking (what do you mean by "child
instances?"), but in any case, PostgreSQL doesn't do any prefetching
("readahead" ) -- we rely on the kernel to do that if and when it's
appropriate.

-Neil

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #6


On Mon, 20 Sep 2004, Neil Conway wrote:
On Sat, 2004-09-18 at 07:42, Ioannis Theoharis wrote:
I'd like to ask you,
if postgres prefetch child instances in memory ,
whenever a parent table is sequentially scanned,
in order to have them in there
for the possibility the next query to ask for them.


I'm not sure exactly what you're asking (what do you mean by "child
instances?"), but in any case, PostgreSQL doesn't do any prefetching
("readahead" ) -- we rely on the kernel to do that if and when it's
appropriate.

-Neil

I mean that i have a "tree" of tables, that has been created using
'inherits' relationship of postgress.
0
1 2
3 4 5 6
Consider this tree. In each node imagine a table. table no 1 inherits
table no 0, table no 3 inherits table 1 ...

The question is, if the table no 0 (root) is secuentially scanned, then
postgress, except from the contents of this table, loads in memory the
contents of tale no 1 or no 2 ?

If the answer is no, then what do you meen "we rely on the kernel to do
that if and when it's appropriate" ?
It's appropriate in my case?
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postg resql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1915
by: Stephan Diehl | last post by:
I have a question about metaclasses: How would be the best way to "merge" different metaclasses? Or, more precisely, what is the best way to merge metaclass functionality? The idea is basicly the following: One has several (metaclass) modules that implements an interesting feature. Lets say, I have a metaclass L, that adds logging capabilities to all method calls and another one, called P, that creates properties on the fly.
17
1830
by: Andrew Koenig | last post by:
Suppose I want to define a class hierarchy that represents expressions, for use in a compiler or something similar. We might imagine various kinds of expressions, classified by their top-level operator (if any). So, an expression might be a primary (which, in turn, might be a variable or a constant), a unary expression (i.e. the result of applying a unary operator to an expression), a binary expression, and so on. If I were solving...
3
1421
by: arserlom | last post by:
Hello I have a question about inheritance in Python. I'd like to do something like this: class cl1: def __init__(self): self.a = 1 class cl2(cl1): def __init__(self): self.b = 2
2
1578
by: Tony Johansson | last post by:
Hello Experts!! Here we use multiple inheritance from two classes.We have a class named Person at the very top and below this class we have a Student class and an Employee class at the same level. There is a class TeachingAssistent that use multiple inheritance from both Student and Employee. There is a method named getName is class Person.
1
1817
by: Tony Johansson | last post by:
Hello Experts! I have some questions about inheritance that I want to have an answer to. It says "Abstract superclasses define a behavioral pattern without specifying the implementation" I know that an abstract class doesn't have any implementaion even if a default implementatiion can be supplied for pure virtual methods. What does it actually mean with saying that an Abstract superclasses define a behavioral pattern?
3
1111
by: Quentin Huo | last post by:
Hi: C# doesn't support multiple inheritance but it supports interface.But I think these ways are different. For example, C++ supports multiple inheritance. I have two classess classA and classB: class classA(){ ......
18
1933
by: Tom Cole | last post by:
I'm working on a small Ajax request library to simplify some tasks that I will be taking on shortly. For the most part everything works fine, however I seem to have some issues when running two requests at the same time. The first one stops execution as the second continues. If I place either an alert between the two requests or run the second through a setTimeout of only 1 millisecond, they both work. You can see a working example here:...
14
2155
by: JoeC | last post by:
I have been writing games and I also read about good programming techniques. I tend to create large objects that do lots of things. A good example I have is a unit object. The object controls and holds everything a unit in my game is supposed to do. What are some some cures for this kind of large object or are they OK because they represent one thing. If not what are better ways to design objects that behave the same way. Would it be...
3
2554
by: Jess | last post by:
Hello, I've been reading Effective C++ about multiple inheritance, but I still have a few questions. Can someone give me some help please? First, it is said that if virtual inheritance is used, then "the responsibility for initializing a virtual base is borne by the most derived class in the hierarchy". What does it mean? Initializing base class is usually done automatically by the compiler, but a derived class can invoke the base...
8
4274
by: Tony Johansson | last post by:
Hello! I wonder can somebody explain when is it suitable to use these methods OnKeyUp, OnKeyDown and OnKeyPress because these raise an event. These are located in class UserControl. If these raise an event how do I create an handler to catch these raised events. //Tony
0
9689
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10495
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10269
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5597
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4148
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2942
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.