kovyrin/db-charmer — Issue #26: [feature request] Database and table sharding
Author: utensil
Created: 2011-10-13 06:09:28+00:00
State: open

For databases and tables splited in various ways, such as:

way database and table name shard by (maybe it's should be called partitioned by?)
YZ.X db_YZ.tb_X order serial number last three digits
YYYYMMDD. db_YYYYMMDD.tb date
YYYYMM.DD db_YYYYMM.tb_ DD date too

, is it possible to use DbCharmer or based on its implementation to have something like:

class Order < ActiveRecord::Base
shard_by :order_serialno do |key|
[get_db_config_by(key), #because some or all of the databaes might share the same machine in a regular way or can be configed by a hash of regex, and it can also be a const
get_db_name_by(key),
get_tb_name_by(key),
]
end
end

detailed information are described at:

http://stackoverflow.com/questions/1659829/how-to-make-activerecord-work-with-legacy-partitioned-sharded-databases-tables

According to the doc, the table-shard part is not considered. I haven't dig into the source yet, just trying to ask the way.

Any help or discussion would be greatly appreciated~~~~