Skip to content

Latest commit

 

History

History

examples

The directory holds examples of how to use the partitioned gem.
These rails scripts will create and populate partitioned tables. The
scripts accept the following parameters:

 --?                   list available options
 --force	       delete tables before starting
                         default: false
 --cleanup	       delete tables and exit
                         default: false
 --create-many         how many objects to create via create_many
                         default: 3000
 --create-individual   how many objects to create via create
                         default: 1000
 --new-individual      how many objects to create via new.save
                         default: 1000
 --update-individual   how many objects to update individually
                         default: 1000
 --update-many         how many objects to update via update_many
                         default: 1000

The scripts are:

company_id.rb: table 'employees' partitioned by company_id

company_id_and_created_at.rb: table 'employees' has multi-level
 partitioning by company_id then created_at created_at is grouped by
 week where weeks start on Monday.

created_at.rb: table 'employees' partitioned by created_at
 created_at is grouped by week where weeks start on Monday.

created_at_referencing_awards.rb: table 'employees' partitioned by
 created_at and table 'awards' is partitioned by created_at which a
 reference to specific child table of employees with the created_at
 range.

id.rb: partitioned on 'id' grouping each 10 records into separate
 child tables.

start_date.rb: grouped by column start_date which is a date grouped
 by month.

The lib directory contains:

by_company_id.rb: a partitioned model where the partition's key is
 the column company_id that references companies.

company.rb: an ActiveRecord model for the table companies.

roman.rb: some helper routines for generating roman numerals.