views:

38

answers:

2

I have a table with millions of rows and I want to create some partions, but I really don't know how I can to this. I mean I want to have the data which is starting with the ID 1 -> 10000 to be on partition one, and and the data that is starting with the ID 10001 -> 20000 to be on partition two; and so on...?Can you give me an example how to do it?

I have searched a lot on the internet and I read a lot of documentation, but I still don't understand how it needs to be done!

Best Regards,

A: 
CREATE TABLE part1 (...)
CREATE TABLE part2 (...)
INSERT INTO part1 SELECT * FROM original WHERE id => 0 AND id < 10000
INSERT INTO part2 SELECT * FROM original WHERE id => 10000 AND id < 20000
Sjoerd
huh? thats not pruning...thats just spliting things up...I need to do that with Mysql partition...
Uffo
You are right, I misunderstood the question.
Sjoerd
+1  A: 

This is how you might start using partitions:

ALTER TABLE table_with_millions_of_rows
PARTITION BY RANGE (id) (
    PARTITION p0 VALUES LESS THAN (10000),
    PARTITION p1 VALUES LESS THAN (20000),
    PARTITION p2 VALUES LESS THAN MAXVALUE
)

Further information on how to manage (create, delete, change settings etc.) partitions can be found in MySQL manual's "Partitioning" chapter.

Note: partitioning in MySQL is available as of version 5.1.

Alexander Konstantinov
I'm getting this error #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PARTITION BY RANGE (id) ( PARTITION p0 VALUES LESS THAN (10000), PARTI' at line 2
Uffo
@Uffo, which MySQL version are you using?
Alexander Konstantinov
Server version: 5.0.90-community-log# MySQL client version: 4.1.22
Uffo
@Uffo, Partitioning is available only since MySQL 5.1, you have to upgrade MySQL in order to use it.
Alexander Konstantinov
@ Alexander Konstantinov Now i'm getting this when I try to partitionate, the engine is MyISAM; and I've also upgraded mysql to 5.1 #1214 - The used table type doesn't support FULLTEXT indexes
Uffo
@Uffo, Everything is in the manual. **Everything**. :) http://dev.mysql.com/doc/refman/5.1/en/partitioning-limitations.html - _"Partitioned tables do not support FULLTEXT indexes. This includes partitioned tables employing the MyISAM storage engine."_
Alexander Konstantinov
Partitioning still doesn't solve my problem, the querys are taking aprox the same time..
Uffo