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 10 Comments
Search This Site
Recent Entries
- Happy Birthday Mom!
- 2008 - A Year in Review
- Portland Tech Meetup Tomorrow Night
- My "almost slept in a snow cave" Adventure with Clint Foster
- My Christmas Travel Adventure
- AppFuse Light converted to Maven modules, upgraded to Tapestry 5 and Stripes 1.5
- Dojo/Comet support in Java Web Frameworks
- Abbie is a Blue Skier!
- How I recovered data from my failed Linux box
- Costa Rica was Awesome!
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 12: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 03:24 AM MST #
Posted by Lego Programmer on April 23, 2008 at 04:26 AM MDT #