Table Sharding
A Yii extension that horizontally partitions large tables for easy searching and faster query.
Requirements ¶
- Yii 1.1.14 (Not yet tested on other version)
- MySQL Table
Table Schema:
CREATE TABLE IF NOT EXISTS 'shardtable' (
'id' int(11) NOT NULL AUTO_INCREMENT,
'columnName' varchar(255) NOT NULL,
'count' int(11) NOT NULL,
'dateSharded' timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY ('id')
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Usage ¶
- Create an extensions folder under protected if none exists.
- Add the php file in your import array
import=>array(
...
'application.extensions.Sharding',
),
- Edit tableName method on your Models
public function tableName()
{
/**
* $tablename refers to the table you want to shard
* $limit refers to the max row of your table
*/
$var = new Sharding('$tablename',$limit);
return $shard->useTable();
}
Contributing ¶
You can contribute to this project by:
- Browse for issues, proposals, and report for bugs.
- Fork my repo, make some changes and issue a pull request.
Whatever contribution is welcomed (may it be constructive criticism, feedbacks, violent reactions, or if you feel that my code is just plain stupid).
Further Features ¶
Features that I will be working on in the near future.
- Asynchronous sharding
- Scheduled sharding
WARNING! USE AT YOUR OWN RISK
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.