-->
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.  [ 12 posts ] 
Author Message
 Post subject: Can shards horizontally partition in a single database?
PostPosted: Thu Jun 14, 2007 8:08 pm 
Regular
Regular

Joined: Thu Jul 29, 2004 11:55 pm
Posts: 75
I am looking for a way to effectively do partitioning in a DB that doesn't support it and we don't need to scale to multiple DB's. Does shards provide that ability? From reading the docs, it seems designed to partition horizontally across databases.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 15, 2007 5:32 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I haven't tried, but I see no problem doing that. Just create one SF config per shard, all SF pointing to the same database

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 17, 2007 1:08 pm 
Contributor
Contributor

Joined: Fri Feb 11, 2005 8:15 pm
Posts: 31
I think the biggest problem you'd run into pointing multiple SessionFactories at the same database is that it violates one of the primary assumptions that Shards currently makes, namely that data is not replicated across your shards. If you point multiple Session Factories at the same database then your data is effectively replicated across all shards, and a query that executes across all shards will return duplicate results. Even attempting to look up a single object would yield strange results because that object actually lives on all shards. Your strategies would probably need to do something strange to make this work.

If your goal is to get single database horizontal partitioning in a db that doesn't support it, I think you're going to need to codify the different partitions in your db schema. That might mean appending a discriminator to the end of each table (Address_US, Address_CA) so that at least each record lives in a distinct shard. Then the issue is getting Shards to support shard-specific table names. At the moment we don't support this (we require each shard to have the same mappings, which includes the table name) but it's certainly something we could consider if people found it useful. Is this something you could maybe use?

Max


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 18, 2007 10:38 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Oh year I forgot that the table names are the same between shards.
This is a constraint that could be dropped though.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 18, 2007 10:56 am 
Contributor
Contributor

Joined: Fri Feb 11, 2005 8:15 pm
Posts: 31
Yes, it could. The trick is to do it in such a way that people don't need to declare a different mapping for each shard. I was looking for a way to dynamically swap out the value of an xml entity so I could do something like this:

table_name="Address&SHARD_ID;"

And then as I set up each SessionFactory provide a different value for SHARD_ID. I'd prefer to do this at the XML parsing layer rather than text replacement but I haven't cracked it yet. Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 18, 2007 11:07 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
inject a custom org.hibernate.cfg.NamingStrategy

(probably wrapping the existing one)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 18, 2007 11:36 am 
Contributor
Contributor

Joined: Fri Feb 11, 2005 8:15 pm
Posts: 31
That would work great for table names, but I'd like to be able to do it in arbitrary places throughout the document (like for cache config attributes).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 18, 2007 6:25 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
the cache regions can be prefixed through a configuration property, so we should be fine for this one too.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 18, 2007 6:38 pm 
Contributor
Contributor

Joined: Fri Feb 11, 2005 8:15 pm
Posts: 31
Stop making it so easy! :-)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 06, 2007 4:58 am 
Regular
Regular

Joined: Mon Apr 25, 2005 9:22 am
Posts: 62
Location: Bucharest/Romania
What if you declare at shard master config level a naming policy? Or is this what Emmanuel already suggested?

./alex
--
.w( the_mindstorm )p.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 07, 2007 2:17 am 
Contributor
Contributor

Joined: Fri Feb 11, 2005 8:15 pm
Posts: 31
That's pretty much what Emmanuel suggested, but I haven't tried to see how it works. Want to give it a shot?

Max


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 07, 2007 2:42 am 
Regular
Regular

Joined: Mon Apr 25, 2005 9:22 am
Posts: 62
Location: Bucharest/Romania
He he... I thought it was what Emmanuel suggested :-). I'll be in vacation for the next 2 weeks, but then I will join the dev discussion group and we will see if I can help.

bests,
./alex
--
.w( the_mindstorm )p.
_____________________________________
Alexandru Popescu, OSS Evangelist
TestNG/Groovy/AspectJ/WebWork/more...
Information Queue ~ www.InfoQ.com


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