A Yii extension that horizontally partitions large tables for easy searching and faster query.
- 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,
`lastPK` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
- 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
*/
$shard = new Sharding('$tablename',$limit);
return $shard->useTable();
}
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).
Features that I will be working on in the near future.
- Asynchronous sharding
- Scheduled sharding
See LICENSE for details.