On Aug 3, 2010, at 6:45 PM, razamatan wrote:

> so our db setup is that we have both vertical and horizontal
> partitioning going on.
> 
> first, is it possible to defined a session as a scoped, sharded
> session to achieve both?  namely, define the shardedsession wrapped by
> a scoped session and simply have the various shard lookup functions
> (*chooser) do the mapping for the vertical partition as well as the
> horizontal ones?  can this be cleanly done by using bind_table on the
> session for the vertically partitioned ones and only have the various
> shard lookup functions concern themselves with the horizontally
> partitioned tables?
> 
> failing the above, it seems pretty straightforward and possible
> (although contrived) to use 2 different sessions (one sharded for
> horizontal and one normal one for vertical w/ the table binds) to
> achieve the same effect.  however, we do lose out on the transaction
> level details spanning all our db sessions.
> 
> thoughts and advice appreciated.  i'm clearly a nub when it comes to
> this stuff.

well unfortunately so are the rest of us, I haven't actually tried using the 
horizontal sharding for anything though I have been aware of people who do.   
The key takeaway from the horizontal shard module is that you can rewrite the 
get_bind() method of Session to do anything you want, and there's just enough 
hooks so that you can get it to call get_bind() for each individual row its 
going to work with.        So for an intricate scheme of database switching, 
the horizontal shard module and/or writing your own get_bind() will definitely 
work though write yourself a bunch of tests.    Over here I have a project 
where I have not quite a horizontal shard scenario, but there are two databases 
used simultaneously - but after trying out a custom get_bind() situation that 
more or less worked, I am using just two separate scoped_sessions, only because 
there's not too much interaction between them and i really didnt want to 
confuse all the other developers, as the second DB isn't really used for most 
of the application.   Its something you need to feel out.




> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalch...@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to