The purpose of this post if to show how you can automate the
creation and pruning of partitioned tables. If you want to read
about partitioning I recommend reading our manual.
In short partitioning makes it possible to spread
your individual tables across a file system according to the
partition rules you specify.
Reasons for partition your tables might be:
- Insert performance, smaller index trees for stable insert
throughput.
- Select performance, only read data from selected (aka
partitioning pruning) partitions.
- Delete performance, drop partitioning is must quicker than
doing range deletes of old data.
Partitioning definitions is part for the CREATE/ALTER table
statements, in …
I got sidetracked today playing with Magic Squares and thought it
might be a good chance to give an example of using MySQL Routines
, Loops and IF checks.
So If you are unaware of what a Magic Square is I have included a
few links. It might save you a Google search but otherwise think
Sudoku as an example.
- http://en.wikipedia.org/wiki/Melencolia_I
- http://en.wikipedia.org/wiki/File:Albrecht_D%C3%BCrer_-_Melencolia_I_%28detail%29.jpg
- http://www.mathematische-basteleien.de/magsquare.htm
- …
So I recently realized that I have not yet talked much about
MySQL partitions.
Many good blog posts on MySQL partitions already exists and I
have listed a few below.
- http://glynndba.blogspot.com/2009/10/rolling-time-based-partitions.html
- http://www.mysqlperformanceblog.com/2010/12/11/mysql-partitioning-can-save-you-or-kill-you/
- http://datacharmer.blogspot.com/2010/05/two-quick-performance-tips-with-mysql.html
- …
I’m observing the process of most awesome SHOW commands being abolished, destroyed and some weird information_schema tables are introduced instead.
Say, even though you can select configuration variables using @@syntax, you can’t do same for much more interesting to DBAs status variables in any more interesting logic.
Apparently instead of doing
SHOW STATUS LIKE "questions"
one has to do this now (I’m being dramatic here, above hasn’t been removed yet, but hasn’t been expanded for better usage either):
SELECT VARIABLE_NAME, VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME="QUESTIONS"
Do note, those SQL standard followers will get caps-lock button swapped with space bar soon.
Of course, we, DBAs, know that one can simplify stuff by creating stored routines:
CREATE FUNCTION `gstatus`(v varchar(64)) returns varchar(1024) return ( SELECT …[Read more]