473,698 Members | 2,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DB2 table design and performance considerations

1 New Member
This question is about DB2 table design and performance.

We are using DB2 UDB Enterprise 8.2 on Linux.

We have 6 tables in a parent-child (one-to-many) relationship with each other. Each child table having an FK up to its parent. This particular design is motivated by our domain model.

A -> B -> C -> D -> E -> F

There is some debate in our team about how best to accomplish this. Two approaches have been discussed.

One alternative is to have a unique ID (UID) as a DECIMAL(0,19) for each PK/FK combination and then do selects for each table based only on this key. I have paraphrased the pseudo SQL as follows:

create table A ( A_UID PK not null, ...):
create table B ( B_UID PK not null, A_UID FK, ...);
create table C ( C_UID PK not null, B_UID FK, ...);
create table D ( D_UID PK not null, C_UID FK, ...);
create table E ( E_UID PK not null, D_UID FK, ...);
create table F ( F_UID PK not null, E_UID FK, ...);

Another approach is to use a UID only at the top table and then have sequence numbers (0,1,2,3, ...) as INTEGER for each additional table as we go down. Therefore to access the top table all we need is a single key.

To select rows from the second table we would need the composite key (FK, SEQ_NO1). To access the third table, C, we would need the composite key (FK, SEQ_NO1, SEQ_NO2). To access the 6th table we would need the composition key (FK, SEQ_NO1, SEQ_NO2, SEQ_NO3, SEQ_NO4, SEQ_NO5). In this case we need all the sequence numbers to fully specify the records we want from the table. Again here is some pseudo SQL which represents the design:

create table A ( A_UID PK not null, ...);
create table B ( B_SEQ_NO not null,
A_UID FK, ...);
PK is composite of (B_SEQ_NO, A_UID)

create table C ( C_SEQ_NO not null,
B_SEQ_NO not null,
A_UID FK, ...);
PK is composite of (C_SEQ_NO, B_SEQ_NO, A_UID)

create table D ( D_SEQ_NO not null,
C_SEQ_NO not null,
B_SEQ_NO not null,
A_UID FK, ...);
PK is composite of (D_SEQ_NO, C_SEQ_NO, B_SEQ_NO, A_UID)

create table E ( E_SEQ_NO not null,
D_SEQ_NO not null,
C_SEQ_NO not null,
B_SEQ_NO not null,
A_UID FK, ...);
PK is composite of (E_SEQ_NO, D_SEQ_NO, C_SEQ_NO, B_SEQ_NO, A_UID)

The belief is that DB2 will already have these records in the same set of pages for the second approach but will not have them for the first approach. So, page caching comes into play for second approach but not the first. The intent is to do the inserts for the cascade with 1 insert statement. So the first approach seems reasonable. But, I would think if the records are scattered on the disk, inserts come in at random times then the second approach is more reasonable.

Hence it is reasoned the second approach will be more performant. Or is it? Does having composite keys cost more?

Do these arguments have any merit?

Thank-you very much in advance.
Apr 22 '09 #1
0 2463

Sign in to post your reply or Sign up for a free account.

Similar topics

36
4646
by: toedipper | last post by:
Hello, I am designing a table of vehicle types, nothing special, just a list of unique vehicle types such as truck, lorry, bike, motor bike, plane, tractor etc etc For the table design I am proposing a single column table with a field name called vehicle_type and this will contain the vehicle type. Sot it will be
133
8538
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
4
3554
by: duoduo | last post by:
I want to know one thing, what is best design for tablespace containers, of course, it is DB2 EE 7.2 on AIX 4.3.3. For example, I have RAID 0+1 storage (8 disks) on EMC Symmetrix. Now I need to create a 64GB tablespace on this EMC RAID. Which of the following is the best way from performance perspective? (1) 1 64GB container (2) 4 * 16GB containers
3
1445
by: Will Honea | last post by:
I just got stuck with cleaning up a mess of records for a group I belong to - circa 80k memebers - that are being kept on a variety of spreadsheets and Access databases by a bunch of different people. Hopeless mess, it is. I happen to have a DB2 license I can use so that's where I want to stuff all this data. I'm no DBA - done a lot of programming for DB2/Oracle over the years even a bit of SAP stuff along with some light weight admin...
1
1541
by: Damon Hart | last post by:
Hi all - I am experiencing continually degrading performance on queries run against the special system tables. I notice the slowdown when these meta-data queries are run implicitly "behind the scenes" such as when psql with readline support tries to complete a table name or pg_admin retrieves table column info to populate the GUI headers. Performance picked up dramatically when I had to dump/restore this weekend. I have not seen any...
7
1136
by: Jonathan Wood | last post by:
I have an idea for several Web sites that would involve articles that can be read. Article lengths will vary from short to a little longer, but nothing really long. I'm wondering at what point does it make sense to include the articles as data in a database, and at what point does it make sense to include a reference to the article in the database but to have the actual article as an existing page. Looking at sites like...
21
3212
by: Johan Tibell | last post by:
I would be grateful if someone had a minute or two to review my hash table implementation. It's not yet commented but hopefully it's short and idiomatic enough to be readable. Some of the code (i.e. the get_hash function) is borrowed from various snippets I found on the net. Thee free function could probably need some love. I have been thinking about having a second linked list of all entries so that the cost of freeing is in proportion to...
48
2626
by: Tony | last post by:
How much bloat does the STL produce? Is it a good design wrt code bloat? Do implementations vary much? Tony
19
3168
by: neelsmail | last post by:
Hi, I have been working on C++ for some time now, and I think I have a flair for design (which just might be only my imagination over- stretched.. :) ). So, I tried to find a design certification, possibly that involves C++, but, if not, C++ and UML. All I could find was Java + UML design certifications (one such is detailed on http://www.objectsbydesign.com/tools/certification.html). Although UML is expected to be language independent,...
0
8674
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
8603
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
9023
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...
1
8893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
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...
1
6518
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
5860
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();...
1
3045
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
1999
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.