I have a large table that I want to spread across multiple disks/LUNs. It will contain blobs and I want to have it separated out from the other data.
How do I go from new disks (lets call them sdb1 and sdc1, the OS, etc. is on sdba1) attached to a (virtual) Linux database server to putting the parts of the database, really one table spread across a couple dedicated devices.
Have looked at the Partition information but its unclear how I change the location of the partitions so everything just doesn't end up in the same data directory.
Best Answer
There is a CREATE TABLE syntax where you can declare the data folder and index folder under the
partition_definition
of apartition_option
:CAVEATS
I know it works for MyISAM because I wrote about it in September 2011 : Dynamically changeable database. For an already existing MyISAM table, it can done from the OS by moving the
.MYD
and.MYI
to another disk and setting up two symlinks. I wrote about that in May 2012 : Can I have one table be an "alias", or "symlink", to another?. When done correctly,SHOW CREATE TABLE
will displayDATA DIRECTORY
andINDEX DIRECTORY
and their respective folders.I personally implemented this in production for a client when I did the following
/var/lib/mysql/mysql/general_log.MYD
to a large 3TB disk/var/lib/mysql/mysql/general_log.MYI
to a large 3TB disk/var/lib/mysql/mysql/general_log.MYD
as a symlink to the real.MYD
/var/lib/mysql/mysql/general_log.MYI
as a symlink to the real.MYI
Option 3 : You Could Monitor the general log
)Using hard links, it can be done to MyISAM tables in Windows, although the effort to do so may not be worth it. I wrote about that back in January 2012 : Can I specify a different disk for a specific MySQL table?
I do not believe
[DATA DIRECTORY [=] 'data_dir']
and[INDEX DIRECTORY [=] 'index_dir']
were implemented for InnoDB. Even if the it were implemented for InnoDB, I would adamently advised against it and I wrote about why you should not back in August 2011 : MySQL InnoDB data file directly on a disk slice (fixed-size)?Your Original Question
MySQL 5.5 Only : With regard to your question in the heading,
Where are partitions defined in mysql
, you can run this query to locate all tables that have partitions:Here is a sample:
You can get the complete definition by running
SHOW CREATE TABLE db.tbl\G
from any table from the result of that query.