Monday May 03, 2004
Creating column indexes with Hibernate One of the best ways to speed up your application's performance is to create or optimize indexes in your database. On my current project, when we created our database on the AS/400 last week, the DBA noticed that there weren't any indexed created. I expected this and said I'd do some research on creating indexes with Hibernate. Thanks to Gavin, it turns out to be quite simple. Let's say you have an XDoclet tag on a column you want to index. Currently it is:
@hibernate.property column="username" not-null="true"
If you're using Hibernate's <schemaexport> task, you can add an index on this column to your mapping file and it'll create the index when creating the database. To add an index, it's as simple as changing the above XDoclet tag to:
@hibernate.property @hibernate.column name="username" not-null="true" index="index_name"
Now the hard part comes. Which columns should you put indexes on? From what I've heard, it's the ones that you use in where clauses of your queries. I expect one or two per table is sufficient (??). One thing I'm not sure of is: should id columns contain an index?
Posted in Java
at May 03 2004, 12:06:44 PM MDT
11 Comments
Search This Site
Recent Entries
- Wine Tasting in Napa Valley
- How to build a Shot-Ski
- Bus Project Update
- Farewell to the 2011-2012 Ski Season
- Cruising around the Western Caribbean
- Spring Break!
- A Spectacular Trip to Stockholm and Madrid
- Comparing Web Frameworks and HTML5 with Play Scala at Jfokus 2012
- Play Framework 2.0 with Peter Hilton at Jfokus
- Secure JSON Services with Play Scala and SecureSocial
Posted by Jason Carreira on May 03, 2004 at 12:11 PM MDT #
Posted by Ted on May 03, 2004 at 12:54 PM MDT #
Posted by dsuspense on May 03, 2004 at 02:13 PM MDT #
Posted by Mark on May 03, 2004 at 02:31 PM MDT #
Posted by dsuspense on May 03, 2004 at 02:39 PM MDT #
Posted by Raymond Phillips on May 04, 2004 at 03:09 PM MDT #
Posted by Harun on January 24, 2005 at 01:59 AM MST #
Posted by James Shepherd on October 26, 2005 at 03:56 PM MDT #
Posted by 202.56.245.58 on November 29, 2007 at 04:24 AM MST #
Posted by Lego Programmer on April 23, 2008 at 04:26 AM MDT #
Posted by 59.177.70.74 on March 24, 2009 at 07:46 AM MDT #