mysql-partitioner 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7bb0ba3d4223d4f8ba5ff0ee0680a74f625d8a6b
4
- data.tar.gz: 54a8acd9478b085803aeec26b898026ad130578a
3
+ metadata.gz: dba04134b4d190b8c7f19da8e026d3fbd5f2e591
4
+ data.tar.gz: 815d422aae033d0bc0fe56a5326a231d9eae99ce
5
5
  SHA512:
6
- metadata.gz: 4ec7efe09a2ff1d1d789d51c29e840a26716ebced29a84bf6676ec811750bb8d96d5cad7c7c817f4c93833dc202e552e01ce2f184778bf37ee8d5589991e7ad4
7
- data.tar.gz: 14b136f672ecfd896eade781c49e0238ab60d0880ebc54be9f226a5c1a2e94c2f1ffe28d54d4360b722d7870a1ae5e9d494f4480d4f4d8c627c0ed954792e6e2
6
+ metadata.gz: bee2b105025933273c7a42d2b0d2079f9728afbccca26918b35717f118a17856a01703d184515d57dc80786a2af0ceba07aa7d5ad033909a8eee49b3b16a61ec
7
+ data.tar.gz: 5cc8f61e685880df9fd0a758c3f81cfaaf8bb3b2423f032f9643cb03892b425b016de6839eb3e9a8b04a517290a28442359ec11721e4556a66090d6db8ce0f4c
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # Mysql::Partition
1
+ # Mysql::Partitioner
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/mysql/partitioner`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Mysql partition management tools
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,25 +20,94 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- `
23
+ ```
26
24
  Usage: mysql-partitioner [options]
27
25
  -c, --config CONFIG_NAME
28
26
  --cmd check or migrate
29
27
  --dry-run
30
28
  -d, --debug
31
- `
29
+ ```
30
+
31
+ sample config
32
+
33
+ * https://github.com/maedama/mysql-partitioner/blob/master/sample/config.yaml
34
+
35
+ ## Features
36
+
37
+
38
+ ### Supported partition type
39
+
40
+ Currently it supports, Range partition without sub partition
41
+
42
+ ### Supported Partition Strategy
43
+
44
+ ##### PartitionByPkDropByRange
45
+
46
+ This Strategy allows us to partition table with Primary Key, and at the same time manage partition by timestamp
47
+
48
+ | Parameter | Description |
49
+ |-----------|-------------|
50
+ | Key | Partition Key |
51
+ | time_key | Time key |
52
+ | min_empty_partitions | If empty partitions is less than this number, check command would fail |
53
+ | desirable_empty_partitions | When migration happens, mysql-partitioner will prepare this number of partitions for future |
54
+ | range | Range of each partitions |
55
+ | ttl | when migration happens tool will drop partitions with all items in partition is older than this ttl |
56
+
57
+
58
+ Typical example of partitioning with timestamp is like bellow.
59
+
60
+ ```
61
+ CREATE TABLE test(
62
+ id big int unsigned NOT NULL,
63
+ content varchar(255) NOT NULL,
64
+ created_at DATETIME NOT NULL,
65
+ PRIMARY KEY(id, created_at)
66
+ ) Engine=InnoDB;
67
+
68
+ ```
69
+
70
+ By including created_at in primary key, mysql can know which partition each data belongs to.
71
+ And each data will be unique if and only if it is unique in the partition they belong to.
72
+
73
+ But this approach has major fallback in terms of performance.
74
+
75
+ i.e Query like bellow would be very slow in such a partitions
76
+
77
+ ```
78
+ SELECT * FROM test WHERE id in (1, 100, 10000,1000000,10000000000000)
79
+ ```
80
+
81
+ Instead of such an partitioning, this strategy partions table like bellow,
82
+
83
+ ```
84
+ CREATE TABLE test(
85
+ id big int unsigned NOT NULL,
86
+ content varchar(255) NOT NULL,
87
+ created_at DATETIME NOT NULL,
88
+ PRIMARY KEY(id, created_at)
89
+ ) Engine=InnoDB;
90
+
91
+ ```
92
+
93
+ When migration happens, toosl find all partitions with following condition and drops them.
94
+
95
+ * Is not most recent active partition
96
+ * All items in partitions is older that specified ttl
97
+
98
+ Additionally tool will also try to make new_partitions with specified parameter
32
99
 
33
100
 
34
101
  ## Example
35
102
 
36
- `
103
+ ```
37
104
  CREATE TABLE `partition_test` (
38
105
  `id` bigint(20) unsigned NOT NULL,
39
106
  `created_at` datetime NOT NULL,
40
107
  `updated_at` datetime NOT NULL,
41
108
  PRIMARY KEY (`id`)
42
109
  ) Engine=InnoDB
43
- `
110
+ ```
44
111
 
45
112
  Initialize first partition
46
113
 
@@ -18,7 +18,7 @@ module Mysql
18
18
  def get_current_partitions
19
19
  results = self.session.query(<<SQL)
20
20
  SELECT PARTITION_EXPRESSION, PARTITION_DESCRIPTION, PARTITION_ORDINAL_POSITION, PARTITION_METHOD, SUBPARTITION_EXPRESSION
21
- FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME="#{ self.table }" AND TABLE_SCHEMA="#{ self.database }"
21
+ FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME="#{ self.table }" AND TABLE_SCHEMA="#{ self.database } ORDER BY PARTITION_ORDINAL_POSITION ASC"
22
22
  SQL
23
23
  results.map {|item|
24
24
  Mysql::Partitioner::Partition::Range.new(item["PARTITION_DESCRIPTION"])
@@ -1,5 +1,5 @@
1
1
  module Mysql
2
2
  module Partitioner
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mysql-partitioner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - maedama