-->
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.  [ 7 posts ] 
Author Message
 Post subject: caching for small tables
PostPosted: Thu Sep 30, 2004 3:34 pm 
Newbie

Joined: Thu Sep 30, 2004 3:17 pm
Posts: 4
I have a table with a few thousand columns. The table changes frequently but only through hibernate (My application is the only application using this database). I have observed that hibernate does not use its cache to run queries after the table is updated.

It seems to me that since the table updates also go through hibernate, hibernated always has the latest data and it should be able to run the queries in memory without hitting the database.

For small tables, that could be loaded in memory and are only accessed by one application, if hibernate could run queries in memory then that would be useful in many applications.

Could you tell me if this feature is already supported or if there are plans to implement this feature?

_________________
Mike


Top
 Profile  
 
 Post subject: Re: caching for small tables
PostPosted: Thu Sep 30, 2004 3:44 pm 
Newbie

Joined: Thu Sep 30, 2004 3:17 pm
Posts: 4
I meant "I have a table with a few thousand rows".
Sorry about that.

_________________
Mike


Top
 Profile  
 
 Post subject: Re: caching for small tables
PostPosted: Mon Oct 04, 2004 4:48 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
thepkm wrote:
It seems to me that since the table updates also go through hibernate, hibernated always has the latest data and it should be able to run the queries in memory without hitting the database.

No, this is way much complex than that. DB can do stuff behind you back (trigger), or queries results based on criteria can evolved because of your update.
Hibernate is not a DB.
You can copy your data to a memory DB such as HSQLDb.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 10:01 pm 
Newbie

Joined: Thu Sep 30, 2004 3:17 pm
Posts: 4
I agree with your point about triggers.

I think that if application developers feel that there are some tables that can be safely loaded into memory then they should have that option. Something like

_________________
Mike


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 05, 2004 6:59 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
Wouldn't you get this functionality by using 2nd-level caching?

_________________
Cheers,
Shorn.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 06, 2004 5:18 pm 
Newbie

Joined: Thu Sep 30, 2004 3:17 pm
Posts: 4
No. 2nd-level caching does not implement this functionality.

To explain why, let's consider 2nd-level caching with query cache and without query cache.

(1) Without query cache:
Hibernate asks the database to run the query and uses its second level cache to load objects.

(2) With query cache:
Hibernate loads query results from its second-level cache. If any of the tables in the query were modified since the query was run then Hibernate will discard the query results and ask the database to run the query again.

Clearly, in both cases, Hibernate makes or is likely to make database calls.

This approach makes sense for many cases.

But as I pointed out in my previous post, there are applications where this approach leads to a fair number of unnecessary database calls. An attribute like "load-table-in-memory" would allow developers to gain substantial performance improvements for such applications.

_________________
Mike


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 06, 2004 6:11 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
my second argument stay correct.

_________________
Emmanuel


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