Overall, it appears that with partitioning, as the data/rows scale, the inserts actually get faster :) This is what I would expect theoretically, so score one for partitioning.
That said, I'm not a benchmark tester, I'm a DBA, so I'm sure plenty of folks could explain why my testing isn't exactly accurate. For the purpose of the tests, I turned off query cache on the servers (though, since the tests were run with primarily inserts, it may not have made much difference). Tables were created with engine=innodb as default.
I do believe, it's enough to suggest going forward with this and doing scale testing on an application with this if you require unique keys that are part of the primary key due to partitioning restrictions in MySQL.
The tables are created for the test:
Sequence Tables:
CREATE TABLE my_test_sequence
(
id integer NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) AUTO_INCREMENT = 1001;
CREATE TABLE my_test_part_sequence
(
id integer NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) AUTO_INCREMENT = 1001;
Non Partitioned Table with PK and Unique Constraint:
CREATE TABLE test_base
(
id INTEGER NOT NULL AUTO_INCREMENT,
other_id INTEGER NOT NULL ,
name varchar(64) ,
PRIMARY KEY (id),
UNIQUE KEY (other_id)
);
Partitioned Table with PK without Unique Constraint:
CREATE TABLE test_part
(
id INTEGER NOT NULL AUTO_INCREMENT,
other_id INTEGER NOT NULL ,
name varchar(64),
PRIMARY KEY (id,other_id)
)
PARTITION BY KEY (id)
PARTITIONS 50;
Partitioned Enforcement Table with for Unique Constraint (Partitions Suggested by Mikael Ronstrom):
CREATE TABLE test_unique_partTrigger for checking unique constraint:
(
other_id INTEGER NOT NULL,
PRIMARY KEY (other_id)
)
PARTITION BY KEY (other_id)
PARTITIONS 50;
DELIMITER /
CREATE TRIGGER enforce_unique
AFTER INSERT ON test_part
FOR EACH ROW BEGIN
INSERT INTO test_unique_part SET other_id = NEW.other_id;
END;
/
DELIMITER ;
test_base.sql insert scripts:
INSERT INTO my_test_sequence VALUES ('');
INSERT INTO test_base (other_id,name) VALUES (last_insert_id(), rand());
First 50,000 Rows (0 to start):
Non-Partitioned with just PK:
$ time mysqlslap -u testing --create-schema=test --query=test_base.sql -c 10 -i 5000 -F ";"Partitioned with alternate table for unique Index:
Benchmark
Average number of seconds to run all queries: 0.100 seconds
Minimum number of seconds to run all queries: 0.028 seconds
Maximum number of seconds to run all queries: 0.211 seconds
Number of clients running queries: 10
Average number of queries per client: 2
real 8m26.624s
user 0m1.154s
sys 0m3.473s
$ time mysqlslap -u testing --create-schema=test --query=test_part.sql -c 10 -i 5000 -F ";"Second 100,000 Rows (50,000 to start):
Benchmark
Average number of seconds to run all queries: 0.051 seconds
Minimum number of seconds to run all queries: 0.020 seconds
Maximum number of seconds to run all queries: 0.376 seconds
Number of clients running queries: 10
Average number of queries per client: 2
real 4m23.382s
user 0m0.892s
sys 0m2.369s
Non-Partitioned with just PK:
$ time mysqlslap -u root --create-schema=test --query=test_base.sql -c 10 -i 10000 -F ";"Partitioned with alternate table for unique Index:
Benchmark
Average number of seconds to run all queries: 0.051 seconds
Minimum number of seconds to run all queries: 0.020 seconds
Maximum number of seconds to run all queries: 0.376 seconds
Number of clients running queries: 10
Average number of queries per client: 2
real 4m23.382s
user 0m0.892s
sys 0m2.369s
$ time mysqlslap -u root --create-schema=test --query=test_part.sql -c 10 -i 10000 -F ";"Third 500,000 Rows (150,000 to start):
Benchmark
Average number of seconds to run all queries: 0.051 seconds
Minimum number of seconds to run all queries: 0.020 seconds
Maximum number of seconds to run all queries: 0.376 seconds
Number of clients running queries: 10
Average number of queries per client: 2
real 4m23.382s
user 0m0.892s
sys 0m2.369s
Non-Partitioned with just PK:
$ time mysqlslap -u root --create-schema=test --query=test_base.sql -c 10 -i 50000 -F ";"Partitioned with alternate table for unique Index:
Benchmark
Average number of seconds to run all queries: 0.081 seconds
Minimum number of seconds to run all queries: 0.018 seconds
Maximum number of seconds to run all queries: 2.069 seconds
Number of clients running queries: 10
Average number of queries per client: 2
real 68m20.086s
user 0m10.791s
sys 0m31.492s
$ time mysqlslap -u root --create-schema=test --query=test_part.sql -c 10 -i 50000 -F ";"
Benchmark
Average number of seconds to run all queries: 0.057 seconds
Minimum number of seconds to run all queries: 0.020 seconds
Maximum number of seconds to run all queries: 0.746 seconds
Number of clients running queries: 10
Average number of queries per client: 2
real 48m50.993s
user 0m8.341s
sys 0m24.062s
2 comments:
This is really interesting. I would like to see your test results starting with, say, one million rows, five million rows, ten million rows and then 100 million. Might be interesting :)
Keith
I would agree - I'll see if I can get those results up soon.
I also plan on posting results from our scale testing that we are starting next week from on of our applications that we've applied partitioning to, so we'll have a more 'real world' workload to get a more accurate workload of the results.
Post a Comment