Skip to content

DBAzine.com

Sections
Personal tools
You are here: Home » Blogs » Craig Mullins Blog » Craig Mullins: Perspectives on Database Management » Bad Standards: #3--Table Limits for Online Joins
Best Practices
For IT best practices, my IT shop uses:
ITIL
CobIT
Balanced Scorecard
Six Sigma
None of the above

[ Results | Polls ]
Votes : 67
 

Bad Standards: #3--Table Limits for Online Joins Bad Standards: #3--Table Limits for Online Joins

With this entry we go back to our continuing series on "bad" database standards.
This is a particularly incorrect standard. Although the idea behind the standard is understandable, the implementation and wording is typically all wrong.

In this case, what I usually see is a standard that states something like this: "Code no more than a 3 table join in any program that is accessed in an online environment."

The idea is to limit the amount of work that is done by a transaction so that it can be accomplished in a limited amount of time. Given that there is a user waiting for a response you do not want the transaction to take an inordinate amount of time. Why is this wrong?

Well, the idea is not wrong, the standard is. Whether it says a 3 table join or a 5 table join (or some other number) is not important. The number of tables participating in a join is not the defining factor. Instead, it is the number of qualifying rows to be returned. A well defined query that specifically limits the data to be returned appropriately, can be very efficient whether it is a single table access or a multiple-table join. So do not place artificial limits on the number of tables that can participate in a join. Each DBMS has its upper limit and, of course, you cannot exceed that (for example, 225 table in DB2 for z/OS).

Another misunderstanding is when standards are written that "worry" about the size of tables. Once again, this factor is not important - instead it is the number of qualifying rows. Consider, for example, a table with 10 million rows in it. A query that uses a matching index to return 2 rows from that table can be very efficient. The number of rows that qualify for the predicates is more important than the size of the table.

You should create standards and guidelines that help your application developers and SQL users to create efficient queries instead of creating arbitrary standards based on table size or number of tables in a join.

© 2005, Mullins Consulting, Inc.

Monday, September 26, 2005  |  Permalink |  Comments (0)
trackback URL:   http://www.dbazine.com/blogs/blog-cm/craigmullins/blogentry.2005-09-26.6751212953/sbtrackback
Craig Mullins
Data Management Specialist
Bio & Writings
Subscribe to my blog Subscribe to my blog
« March 2006 »
Su Mo Tu We Th Fr Sa
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
2006-03-02
00:54-00:54 The Problem with Prediction
2006-03-04
18:52-18:52 Data Privacy Policies
 
 

Powered by Plone