-->
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.  [ 11 posts ] 
Author Message
 Post subject: Query cache
PostPosted: Tue Sep 09, 2003 1:00 pm 
Newbie

Joined: Fri Aug 29, 2003 8:02 pm
Posts: 8
One thing I've been milling around in my head for awhile in the JBoss CMP world is the concept of a query cache and I'm wondering if the concept could be applied to the Hibernate world.

Here are the parameters for a simply implemented query cache:

- Hibernate has sole access to datasource
- Access is read-mostly

This is how it would work.

1. Whenever a query is made, the fully expanding String of the query is stored in a hashmap (as the key), along with the result set (the value).

2. Whenever an update happens, the update figures out exactly what tables/object types are affected. Any query that is cached that is using any of these tables/object types is invalidated/flushed from the query cache.

I'm wondering if this is feasible to implement or even makes sense in the HB world.

Bill

_________________
============
Bill Burke
Chief Architect
JBoss Group, LLC
============


Top
 Profile  
 
 Post subject: reply to this.
PostPosted: Tue Sep 09, 2003 1:01 pm 
Newbie

Joined: Fri Aug 29, 2003 8:02 pm
Posts: 8
setting up email notify so I can be notified when somebody responds.

_________________
============
Bill Burke
Chief Architect
JBoss Group, LLC
============


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 09, 2003 10:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Its _possible_. But I suspect that the usecases where it would actually result in a real performance improvement are very narrow.

Its been my view that caching of query results is something better handled in the application. But I can be persuaded otherwise, I guess...


Top
 Profile  
 
 Post subject: usecase?
PostPosted: Tue Sep 09, 2003 11:04 pm 
Newbie

Joined: Fri Aug 29, 2003 8:02 pm
Posts: 8
www.djindexes.com is a usecase. I implemented a custom query cache for them for ejb finders. It is a read mostly sight. DB CPU utilization went from 100% to 2%.

I implemented a similar strategy for a similar client Banta media that had read mostly data they did reports on.

_________________
============
Bill Burke
Chief Architect
JBoss Group, LLC
============


Top
 Profile  
 
 Post subject: Re: usecase?
PostPosted: Tue Sep 09, 2003 11:06 pm 
Newbie

Joined: Fri Aug 29, 2003 8:02 pm
Posts: 8
patriot1burke wrote:
www.djindexes.com is a usecase. I implemented a custom query cache for them for ejb finders. It is a read mostly sight. DB CPU utilization went from 100% to 2%.

I implemented a similar strategy for a similar client Banta media that had read mostly data they did reports on.


One more thing, anytime you're doing reporting mostly, like a decision support system or something, you'll want to cache queries.

Bill

_________________
============
Bill Burke
Chief Architect
JBoss Group, LLC
============


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 09, 2003 11:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
ok, but in ejb, it is not really possible to do this caching in the application layer. In Hibernate it is. ('Cos of full detached object support.)

What you have to convince me is that there are big advantages doing it in Hibernate, rather than in the application.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 15, 2003 5:40 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
gavin wrote:
What you have to convince me is that there are big advantages doing it in Hibernate, rather than in the application.


Bill wanted to invalidate query if any of the object types related to it were updated.
It's not easy for an application to know which type is involved in a query when the select clause is restrictive (return cat out of a cat and dog from clause). Parsing and inheritance work is already done by hibernate.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 15, 2003 8:54 am 
Senior
Senior

Joined: Wed Aug 27, 2003 6:04 am
Posts: 161
Location: Linz, Austria
epbernard wrote:
gavin wrote:
What you have to convince me is that there are big advantages doing it in Hibernate, rather than in the application.


Bill wanted to invalidate query if any of the object types related to it were updated. Parsing and inheritance work is already done by hibernate.


That's a convincing argument: Hibernate would know when to invalidate a cached query; it's hard for an application to implement this (maybe possible via an Interceptor, but not really feasible).

So I'd like to revive the discussion: IMO, it would make indeed sense to introduce query caching to Hibernate.

Juergen


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 15, 2003 9:01 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Guys, this functionality is already in 2.1 beta 4!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 15, 2003 9:51 am 
Senior
Senior

Joined: Wed Aug 27, 2003 6:04 am
Posts: 161
Location: Linz, Austria
gavin wrote:
Guys, this functionality is already in 2.1 beta 4!


Oh :-) Great! I should have done my homework, I guess ;-)

Juergen


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 15, 2003 9:58 am 
Senior
Senior

Joined: Wed Aug 27, 2003 6:04 am
Posts: 161
Location: Linz, Austria
gavin wrote:
Guys, this functionality is already in 2.1 beta 4!


Oh :-) Great! I should have done my homework, I guess ;-)

Juergen


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