Fancy partitioning scheme

Fancy partitioning scheme

am 02.06.2010 21:29:48 von bcantwell

Perhaps someone has already accomplished this:

I have a simple table with 3 columns:
mytable(
myid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
myunixtime INT(11) NOT NULL DEFAULT 0,
myvalue BIGINT(20) UNSIGNED NOT NULL DEFAULT 0
)
It is collecting millions of rows.
The myunixtime column is a unix timestamp column.
I'd love to know if it is possible to partition the table so that the
partitions would be something like:

partition A = everything one day or less old,
partition B = everything 7 days old or less,
partition C = everything 31 days old or less,
partition D = everything older than 31 days.

Can partitioning be this dynamic? If not, what solution could be
suggested to handle doing date range queries on this table that can have
10's or 100's of millions of rows?




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

RE: Fancy partitioning scheme

am 02.06.2010 21:49:50 von Gavin Towey

TXlTUUwgZG9lc24ndCBzdXBwb3J0IGR5bmFtaWMgZGlzdHJpYnV0aW9uIG9m IGRhdGEgYW1vbmcg
cGFydGl0aW9ucy4gIFRoZSB1c3VhbCBtZXRob2QgaXMgdG8gY3JlYXRlIGEg cGFydGl0aW9uIGZv
ciBlYWNoIGZpeGVkIGNodW5rIG9mIHRpbWUsIHN1Y2ggYXMgZm9yIGVhY2gg bW9udGgvd2Vlay9o
b3VyL2RheSBvciB3aGF0ZXZlciB0aW1lIHNsaWNlIGJyZWFrcyB5b3VyIGRh dGEgdXAgaW4gdGhl
IG1hbmFnZWFibGUgcGllY2VzLiAgIE5vdGUgdGhhdCBhIHZlcnkgbGFyZ2Ug bnVtYmVyIG9mIHBh
cnRpdGlvbnMgKCA+IDEwMDAgaXNuJ3QgcmVhbGx5IHJlY29tbWVuZGVkLikN Cg0KT3RoZXIgbm90
ZXM6DQpQZXJzb25hbGx5LCBJIGF2b2lkIHNjaGVtYS1sZXNzIGNvbnN0cnVj dGlvbnMgbGlrZSB0
aGlzLCBiZWNhdXNlIHRoZXkgYXJ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