Monday, April 30, 2012

MySQL Innodb Size Reduction by Partitioning

I've faced space limitation on hard dis, so finally found partitioning as a good option to manage old data for removing and freeing space (innodb doesn't free deleted data space back to OS). By partitioning you can discard a partition for example 1 month data and it release the used space by that partition file.

You can delete unused data from table before execute it, to free some space on just partitioning without truncating a partition.

This is the batch query for slicing a table, Using a temp table to prevent lock of update query while partitioning.

ALTER TABLE EventLog RENAME TO  EventLogTmp;

CREATE TABLE  EventLog (
    DateTime datetime NOT NULL,
    Node varchar(16) NOT NULL,
    Event varchar(512) NOT NULL,
    Count int(10) unsigned NOT NULL,
    PRIMARY KEY (DateTime , Node , Event) USING BTREE
ENGINE=InnoDB DEFAULT CHARSET=latin1;

ALTER TABLE EventLogTmp
Partition by Range(Year(DateTime))
(
Partition OldYearsP Values Less Than(2010),
Partition Y2010P Values Less Than(2011),
Partition Y2011P Values Less Than(2012),
Partition Y2012P Values Less Than(2013),
Partition Y2013P Values Less Than(2014),
Partition Y2014P Values Less Than(2015),
Partition FutYearsP Values Less Than(2050)
);

ALTER TABLE EventLog RENAME TO EventLogTmp3;

ALTER TABLE EventLogTmp RENAME TO  EventLog;

INSERT INTO EventLog Select * From EventLogTmp3;


DROP TABLE EventLogTmp3;

If you made a backup of one partition data and this partition can't be used more like this sample that partition table base on year, you can drop the whole partition.

ALTER TABLE EventLog DROP PARTITION OldYearsP;

If you want to rotate a partition like monthly partition, you can make backup of data and then truncate data inside.

ALTER TABLE EventLog TRUNCATE PARTITION Y2012P;

Saturday, March 3, 2012

SSHd close connection (MaxStartUp)

In case of getting close connection from ssh server and starting multi session concurrently (like a cron job include some session to run command), check and increase the MaxStartUp parameter in /etc/ssh/sshd_config.

Wednesday, February 22, 2012

Apartheid in Parking Lot

I just called to move out my car from my company alley because of my ID card color (RED). Because this is company policy to allow Blue card guys (internals) use the alley and parking of company.

* funny part is that alley is public place and is not for company at all

I really surprised and don't expect it from an international company, headquarter based on one of the socialist Scandinavia.

Wednesday, October 19, 2011

A Bit of Documentation

Every bit of documentation is worth as much as every line of that code. Document it, even for your Hello World.

God Bless You Dennis

Sunday, February 27, 2011

Advice

Writing a long email is exciting, but reading them is prosaic;

Sunday, November 7, 2010

Bribery

"the practice of offering something (usually money) in order to gain an illicit advantage"

The first question is should I accept it where most or all people do it, so the first answer is absolutely not, it is not moral. But when it becomes part of organization culture and provide better opportunities for whom got it what can do. What must do when your manager or top level officers do ? Leaving the company is a good option if possible.

The worse thing is that you face it in technological company, where you expect the skills & ingenuity is the scale of progress & promotion.

These are just the questions.