Java Performance Tuning

Java(TM) - see bottom of page

|home |services |training |newsletter |tuning tips |tool reports |articles |resources |about us |site map |contact us |

Our valued sponsors who help make this site possible
New Relic: Try free w/ production profiling and get a free shirt! 

ManageEngine's Site24x7: End-to-End analysis on Java EE web transactions. Sign up for FREE! 

AppDynamics: Get complete browser to backend visibility. Monitor Now! 

Question of the month: Primary Key Efficiency

Chart Java Jitter with jHiccup
Monitor and identify pauses in your Java apps. Download now

Why is my application so slow?
Learn 3 ways to detect Java Application Performance Trends

perfino
Easy and powerful JVM monitoring; Instant access to live demo


Java Performance Training Courses
COURSES AVAILABLE NOW. We can provide training courses to handle all your Java performance needs

See Your Message Here
You could have your tool advertised here, to be seen by thousands of potential customers

Java Performance Tuning, 2nd ed
The classic and most comprehensive book on tuning Java

Java Performance Tuning Newsletter
Your source of Java performance news. Subscribe now!
Enter email:


New Relic
New Relic: Try free w/ production profiling and get a free shirt!

ManageEngine
ManageEngine's Site24x7: End-to-End analysis on Java EE web transactions. Sign up for FREE!

AppDynamics
AppDynamics: Get complete browser to backend visibility. Monitor Now!


Chart Java Jitter with jHiccup
Monitor and identify pauses in your Java apps. Download now

Why is my application so slow?
Learn 3 ways to detect Java Application Performance Trends

perfino
Easy and powerful JVM monitoring; Instant access to live demo


Back to newsletter 040 contents

Why is a long primary key bad for performance?

There are always lots of new things to find out about Java performance, even for the performance experts. I recently had the pleasure of sitting through Carol McDonald's Sun tech day presentation on J2EE performance. Even despite having a power cut causing a longish delay in the middle, this was easily the best presentation of the two day event.

One point she made was that long primary keys were bad for performance. I can easily believe this but it was new to me, so later I asked Carol for clarification on why this should be. Back she came with a detailed listing of the performance effects of primary keys, and I'm delighted to share these details with you. The following tips and references are all courtesy of Carol.

From "Bitter EJB"

"a longer key will require more computation to hash or compare than a shorter primary key" chapter 7 page 234.

What Makes a Good Primary Key?

Good primary keys are essential to good database design. They let you query and modify each table row individually without changing other rows in the same table. When you evaluate candidates for a table's primary key, follow these rules:

Tips on Optimizing SQL Server Indexes

Keep the "width" of your indexes as narrow as possible. This reduces the size of the index and reduces the number of disk I/O reads required to read the index, boosting performance.

If possible, try to create indexes on columns that have integer values instead of characters. Integer values have less overhead than character values.

Don't use FLOAT or REAL data types for primary keys, as they add unnecessary overhead and can hurt performance.

Indexes on narrow columns are preferable to indexes on wide columns. The narrower the index, the more entries SQL Server can fit on a data page, which in turn reduces the amount of I/O required to access the data.

SQL Server Performance Tuning for SQL Server Developers

Reduce the size of the keys, thus decreasing read I/O during the join process, and increasing overall performance.

My thanks to Carol for answering my question this month.

The JavaPerformanceTuning.com team


Back to newsletter 040 contents


Last Updated: 2014-08-27
Copyright © 2000-2014 Fasterj.com. All Rights Reserved.
All trademarks and registered trademarks appearing on JavaPerformanceTuning.com are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries. JavaPerformanceTuning.com is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
URL: http://www.JavaPerformanceTuning.com/news/qotm040.shtml
RSS Feed: http://www.JavaPerformanceTuning.com/newsletters.rss
Trouble with this page? Please contact us