-->
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.  [ 3 posts ] 
Author Message
 Post subject: Maintaining identical tables
PostPosted: Thu Mar 25, 2010 4:46 pm 
Newbie

Joined: Thu Mar 25, 2010 4:35 pm
Posts: 2
I need to implement something rather strange. My application creates internal application sessions for interacting with the client. Session is basically a db record with a unique ID.
The session needs to be stored forever, even after the client had disconnected.

The problem is that ACTIVE sessions need to be checked very often, while FINISHED sessions are used only by reporting.

If I put them both in the same table, then finding ACTIVE session will become progressively slower as the number of old sessions grows. Indexing on “active” flag will not help as it will have very low selectivity.

If I put them in separate tables then I need to create two identical entities in the application.

I’m wondering if there is some elegant solution to this.

Thanks,
Philopator.


Top
 Profile  
 
 Post subject: Re: Maintaining identical tables
PostPosted: Fri Mar 26, 2010 6:01 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
Indexing on “active” flag will not help as it will have very low selectivity.


I'm not agree with this.
If you have for example 10 sessions with 'active' flag and 100.000 sessions with flag set to 'finished',
then a query like "from Session where flag='active'" should indeed profit extremely from the existence the index on the flag column,
because In this case you have a extremely high selectivity (1:10.000).
You have only low selectivity if you query "from Session where flag='finished'" (selectivity ~ 1:1)
but this query is not so relevant to you.
You must distinct GENERAL selectivity of boolean values (which is very low as we know),
from SPECIFIC selectivity of boolean values (=for a determinate boolean value),
which in your specific case is extremely high.

regards
Guenther D.


Top
 Profile  
 
 Post subject: Re: Maintaining identical tables
PostPosted: Mon Mar 29, 2010 5:47 pm 
Newbie

Joined: Thu Mar 25, 2010 4:35 pm
Posts: 2
pb00067 wrote:
You must distinct GENERAL selectivity of boolean values (which is very low as we know),
from SPECIFIC selectivity of boolean values (=for a determinate boolean value),
which in your specific case is extremely high.


You're probably right - we'll check it out.

Thanks for the reply.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.