-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Index on discriminator column
PostPosted: Tue Jul 04, 2006 8:12 am 
Beginner
Beginner

Joined: Sat Apr 15, 2006 12:49 pm
Posts: 20
Location: austria
Hi,

I have a rather general question: Does it make sense, to use a db index on a discriminator column? I have the following annotations on a superclass that is extended by to sublcasses:

Code:
@Entity
@Table(name = "tblSubject")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@org.hibernate.annotations.Table(appliesTo="tblSubject", indexes={
      @Index(name="tblSubject_idx_type", columnNames={"type"})})
@DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.STRING, length = 4)
public abstract class Subject ....


Is this a common practice or is it better to omit the index when only 2 different values (i.e. the discriminator values of the 2 sub classes) can appear on the type column?

thx,

john


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 04, 2006 10:16 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Depends on the database provider, number of data, query types, ...
More of a DBA question.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 04, 2006 12:27 pm 
Beginner
Beginner

Joined: Sat Apr 15, 2006 12:49 pm
Posts: 20
Location: austria
sounds reasonable, I was just wondering if there were some basic rules considered as best practice...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 04, 2006 12:27 pm 
Beginner
Beginner

Joined: Sat Apr 15, 2006 12:49 pm
Posts: 20
Location: austria
sounds reasonable, I was just wondering if there were some basic rules considered as best practice...

(accidently sent twice)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 07, 2006 9:23 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
this is usually a bad practice since your index is not discriminative enough.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.