473,659 Members | 3,631 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Any reason not to use inheritance?

jao
My company's product uses Postgres 7.4.3. Postgres is working well for
us, and we've worked through many performance issues by tweaking the
schema, indexes, and posgresql.conf settings.

Inheritance would be useful for our application, but we did not use
this feature initially. We're about to revise part of our application,
and this would be a good time to introduce inheritance -- it's a good
fit for our data model, and it would greatly simplify some of our
upcoming work.

I'd really like to use inheritance, but not if I'm asking for trouble.
The question is whether there are any performance-related surprises
lurking. Our use of inheritance would be very simple:

- The columns that would be inherited are not involved in any primary
or foreign keys.

- One of the columns would be used in indexes on some of the child
tables. In these cases, the index would combine an inherited column
with a column declared in an inheriting table.

- Queries will often restrict the inherited indexed column.

- We'll occasionally ORDER BY inherited columns.

Any reason not to use inheritance?

Jack Orenstein
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #1
5 2865
Just beware that inheritance is not a complete methodology in postgres.
The implementation has limitations. For instance, indexes in parent
tables will not be inherited by children.

I've yet to encounter a scenario that actually required inheritance.
I've used it a few times, but when I have, the end result always
required a bit more work because of the incomplete aspects of the
postgres implementation (namely constraints and indexes).

-tfo

On Sep 20, 2004, at 4:03 PM, ja*@geophile.co m wrote:
My company's product uses Postgres 7.4.3. Postgres is working well for
us, and we've worked through many performance issues by tweaking the
schema, indexes, and posgresql.conf settings.

Inheritance would be useful for our application, but we did not use
this feature initially. We're about to revise part of our application,
and this would be a good time to introduce inheritance -- it's a good
fit for our data model, and it would greatly simplify some of our
upcoming work.

I'd really like to use inheritance, but not if I'm asking for trouble.
The question is whether there are any performance-related surprises
lurking. Our use of inheritance would be very simple:

- The columns that would be inherited are not involved in any primary
or foreign keys.

- One of the columns would be used in indexes on some of the child
tables. In these cases, the index would combine an inherited column
with a column declared in an inheriting table.

- Queries will often restrict the inherited indexed column.

- We'll occasionally ORDER BY inherited columns.

Any reason not to use inheritance?

Jack Orenstein

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postg resql.org

Nov 23 '05 #2
jao
Quoting "Thomas F.O'Connell" <tf*@sitening.c om>:
Just beware that inheritance is not a complete methodology in postgres.
The implementation has limitations. For instance, indexes in parent
tables will not be inherited by children.

I've yet to encounter a scenario that actually required inheritance.
I've used it a few times, but when I have, the end result always
required a bit more work because of the incomplete aspects of the
postgres implementation (namely constraints and indexes).


Could you expand on this?

All indexes and constraints would be declared on the child tables.
Nearly all table reference would be to the child tables. (So why use
inheritance at all? If for no other reason, all the common
columns would be declared in one place.)

Jack Orenstein

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

---------------------------(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 #3
Unique columns in the parent tables can't be guaranteed except with
triggers. Since I like my data models to be unable to go incoherent
(who doesn't) you end up putting triggers on those tables which is
paying performance & implementation complexity for something that just
works with normal tables.

I was also lured into using inheritance since it looked so logical. But
I went back to a master table + separate tables instead of children.

Unless you have a compelling reason I'd stay away.

David Helgason,
Over the Edge (http://otee.dk), making great game technology
On 21. sep 2004, at 00:16, ja*@geophile.co m wrote:
Quoting "Thomas F.O'Connell" <tf*@sitening.c om>:
Just beware that inheritance is not a complete methodology in
postgres.
The implementation has limitations. For instance, indexes in parent
tables will not be inherited by children.

I've yet to encounter a scenario that actually required inheritance.
I've used it a few times, but when I have, the end result always
required a bit more work because of the incomplete aspects of the
postgres implementation (namely constraints and indexes).


Could you expand on this?

All indexes and constraints would be declared on the child tables.
Nearly all table reference would be to the child tables. (So why use
inheritance at all? If for no other reason, all the common
columns would be declared in one place.)

Jack Orenstein

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

---------------------------(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

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postg resql.org

Nov 23 '05 #4
If the scope of your inheritance (as in, number of children you expect
per parent) is reasonably limited, this can be convenient. But if the
number of children grows large, and you discover that you need indexing
or constraints, you will need to develop triggers that can manage
everything and generally spend a bit more time on manual intervention
than if you relied on a normalized data model.

-tfo

On Sep 20, 2004, at 5:16 PM, ja*@geophile.co m wrote:
I've yet to encounter a scenario that actually required inheritance.
I've used it a few times, but when I have, the end result always
required a bit more work because of the incomplete aspects of the
postgres implementation (namely constraints and indexes).


Could you expand on this?

All indexes and constraints would be declared on the child tables.
Nearly all table reference would be to the child tables. (So why use
inheritance at all? If for no other reason, all the common
columns would be declared in one place.)

Jack Orenstein

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

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

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

Nov 23 '05 #5
ja*@geophile.co m wrote:
Any reason not to use inheritance?


Inheritance is certainly very useful/convenient especially for "table
partitioning" (though not the same as in Oracle) and for modeling
supertype-subtype stuffs.

The only drawback I see is that the implementation is still lacking in
several area, e.g. no hierarchy-wide unique constraints, so you'll have
to resort to triggers. And there doesn't seem to be many people using it
at the moment, so if there were a bug then it might get fixed less quickly.

Ironically, the last sentence could be argued as the reason *to* use
inheritance in Postgres, to get more people using and testing it. :-)

--
dave

---------------------------(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 #6

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

Similar topics

11
3232
by: Ricky Romaya | last post by:
Hi, Are there any ways to get multiple inheritace in PHP4? For example, I have 3 parent class, class A, B, and C. I want class X to inherit all those 3 classes. Consider merging those 3 classes is out of the question, as there are class Y which only inherits from class A, etc. TIA
0
1456
by: John Hunter | last post by:
I am using pycxx 5.2.2 to implement some extension code and have a problem relating to inheritance. I have a pure virtual base class and two concrete derived classes. In the code below, everthing works fine in that the derived classes can use the base method get, but if I try and add a method only available to Derived2, eg, get2, I get a compiler error on the call to add_varargs_method("get2",&Derived2::get2, "get2()\n"); in...
2
4369
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two files containing some templates: adjacency_list.hpp and mem_fn.hpp can not compile. Does anyone have any solutions?
2
4328
by: Graham Banks | last post by:
Does using multiple inheritance introduce any more performance overhead than single inheritance?
4
12812
by: Dave Theese | last post by:
Hello all, The example below demonstrates proper conformance to the C++ standard. However, I'm having a hard time getting my brain around which language rules make this proper... The error below *should* happen, but my question to the community is *why* does it happen? Any answer will be appreciated, but a section and paragraph number from the C++ Standard would be especially appreciated.
5
2176
by: Morgan Cheng | last post by:
It seems no pattern defined by GoF takes advantage of multiple inheritance. I am wondering if there is a situation where multiple inheritance is a necessary solution. When coding in C++, should multiple inheritance still be avoided? If yes, why multiple inheritance is introducted into C++?
10
2650
by: davidrubin | last post by:
Structural inheritance (inheriting implementation) is equivalent to composition in that a particular method must either call 'Base::foo' or invoke 'base.foo'. Apparantly, The Literature tells us to prefer composition over inheritance. Can anyone provide some reasons why this is the case (based on "real-world" experience)? For example, is structural inheritance more difficult to maintain? More difficult to test? Have a larger impact on...
60
4903
by: Shawnk | last post by:
Some Sr. colleges and I have had an on going discussion relative to when and if C# will ever support 'true' multiple inheritance. Relevant to this, I wanted to query the C# community (the 'target' programming community herein) to get some community input and verify (or not) the following two statements. Few programmers (3 to7%) UNDERSTAND 'Strategic Functional Migration
6
3812
by: Bart Simpson | last post by:
I remember reading on parashift recently, that "Composition is for code reuse, inheritance is for flexibility" see (http://www.parashift.com/c++-faq-lite/smalltalk.html#faq-30.4) This confused me somewhat as I have always thought you get code reuse "for free" with inheritance. Am I missing something?. Will someone care to explain ??
0
8337
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
8851
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
8628
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
7359
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
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.