Skip to content
This repository has been archived by the owner on Oct 3, 2019. It is now read-only.
/ TableSharding Public archive

A Yii extension that partitions horizontally large tables for easy searching and faster query

License

Notifications You must be signed in to change notification settings

mateeyow/TableSharding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Table Sharding

A Yii extension that horizontally partitions large tables for easy searching and faster query.

Requirements

  1. Yii 1.1.14 (Not yet tested on other version)
  2. 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 ;

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
   */
  $shard = new Sharding('$tablename',$limit);
  return $shard->useTable();
}

Contributing

You can contribute to this project by:

  1. Browse for issues, proposals, and report for bugs.
  2. 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.

  1. Asynchronous sharding
  2. Scheduled sharding

License

See LICENSE for details.

WARNING! USE AT YOUR OWN RISK

About

A Yii extension that partitions horizontally large tables for easy searching and faster query

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages