Environment: OS: MS Windows 2012 R2, CPU: Xeon 12 logical processors, HDD Block Size: 8 KB, DB engine (MariaDB 10.1.23 Or MariaDB 10.2.6 Or MySQL 5.7.18) with Default Settings.
Schema:
CREATE DATABASE IF NOT EXISTS `z` DEFAULT CHARACTER SET utf8;
CREATE TABLE `test` (
`testId` BIGINT(20) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`testId`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
- Use below mysqlslap to make 1 Million records without concurrency (single thread, single connection) :
mysqlslap -pPutPASS --create-schema=z --number-of-queries=1000000 --query="insert into test values(null)"
test.ibd size: 36.0 MB (37,748,736 bytes)
- Truncate/empty the table and perform concurrency insert as below:
mysqlslap -pPutPASS --create-schema=z --concurrency=100 --number-of-queries=1000000 --query="insert into test values(null)" --commit=10000
test.ibd size: 56.0 MB (58,720,256 bytes)
- Set innodb_thread_concurrency=12 and repeat step 2:
test.ibd size: 76.0 MB (79,691,776 bytes) and sometimes 72 MB. also I tested with --concurrency=500 and table size became 88.0 MB
- the actual optimized size is 28 MB by using:
OPTIMIZE TABLE
z
.test
;
Update 1:
Above test.ibd size results valid for MariaDB 10.1.23.
For MariaDB 10.2.6 test.ibd size:
36 MB (without concurrency)
88 MB (concurrency insert with innodb_thread_concurrency=0)
92 MB (innodb_thread_concurrency=12)
40 MB (optimized)
For MySQL 5.7.18 test.ibd size:
36 MB (without concurrency)
68 MB (concurrency insert with innodb_thread_concurrency=0)
72 MB (innodb_thread_concurrency=12)
40 MB (optimized)
The difference of 10.2.6 & 5.7.18 from 10.1.23 mostly due to barracuda "innodb_file_format" which seems worst than the old format as above tests shows!
Questions:
- Why InnoDB table size increased by big factor when I use concurrent Insertion?
- Why innodb_thread_concurrency causing the table size to be tripled and nothing mentioned in official docs regarding that?!
- What are the config tweaks that make MariaDB/MySQL benefit from the concurrency performance boost WHILE keeping the table size smallest? I am planning to use innodb_thread_concurrency=0 as explained in Hyperthreading & MySQL InnoDB Thread Concurrency Performance but that's not enough, my project will have billions of records and keeping the table size as small as possible will be big gain for performance and saving of H/W resources.
Update 2:
Until I get an answer for the above questions, I will highlight my project requirements in order to get best configuration:
Production Environment:
OS: MS Windows 2012 R2
SDD: HPE 1.92TB SATA 6G Mixed, Block Size 4 KB
RAM: 768 GB
CPU: 4 Xeon Processors (Sockets) E7-8890 V3 2.5 GHZ (total cores: 72, total logical processors: 144)
Data: 150 inserts per second, 24X7, from 50 to 150 connections, single-row inserted. Avalibilty of data is 1 year (mean any record older than 1 year will be deleted), no updates on the rows, just insert once, then selecting/querying through web UI), one year data estimated to be 3-4 Billion rows. DB schema consist of one big table and 10 tables holding metadata (ex: country, etc), biggest metadata table will hold maximum of 3000 rows during the whole project life cycle. so the main focus is the big table.
So far I adjusted below config params:
max_connections=501
innodb_flush_log_at_trx_commit = 0
innodb_log_buffer_size = 256M
innodb_buffer_pool_size=512G
innodb_log_file_size=1G
max_allowed_packet = 1G
innodb_flush_method=async_unbuffered
innodb_flush_neighbors=0
innodb_io_capacity=400
innodb_io_capacity_max=2000
innodb_log_compressed_pages=off
innodb_write_io_threads = 12
innodb_doublewrite = off
innodb_read_io_threads = 12
skip_name_resolve=ON
# dump/restore buffer pool, faster buffer pool warmup
innodb_buffer_pool_dump_at_shutdown = ON
innodb_buffer_pool_load_at_startup = ON
innodb_page_size=4k
Please Suggest (with Explanation) further config tweaks I need in order to get the best of InnoDB and MariaDB 10.2.6