bitsCN.com
Mysql的版本和存储引擎较多,为了选择最适合业务使用的系统,需要进行一定的验证,本文描述mysql的验证过程和思路。
主要涉及:
Mysql的版本
v Mariadb
v Tokudb
v Oracle
具体的存储引擎
v Myisam
v Innodb
v TokuDB
v Maria
如下是具体的思路
My.cnf配置
log-bin=mysql-bin 关闭,不要写日志
skip-networking 开启
安装和配置
v mariadb5.5
v Oracle
v Tokudb
如上目录下有对应的安装,卸载脚本
具体步骤如下:
1.首先停止mysql服务
a) service mysql stop / service mysqld stop
b) killall -9 mysql | killal -9 mysqld
c) /etc/profile中不要有mysql的环境变量设置
2.安装引擎
a) 以上的各个对应目录有安装的脚本
3.检验
a) 进入对应的安装目录下的bin目录
b) ./mysql -uroot -p123456 检查安装的版本信息是否正确
c) show engines; show plugins; 可以查看引擎的安装情况
4.运行单元测试验证各个引擎的性能
单元测试[Gtest]
基础插入函数
包括
v 迭代次数
v 存储包的大小:数据字段可设置大小
###是具体的业务表
static void insertOneSession(int count, int size, bool canTruncate = true){
### item = createItem(size);
cppdb::session session;
static const std::string sql =
"insert into `###`) /
VALUES ( ?, FROM_UNIXTIME(?), ?, ?, ?, ?, ?, /
INET_ATON(?), ?, ?, ?, ?, ?, /
?, ?, ?)";
{
try {
session = cppdb::session(::common::base::BaseData::dbConnectString);
cppdb::statement stmt;
if (canTruncate) {
const static string ready = "TRUNCATE table ***";
stmt = session.prepare(ready);
stmt.exec();
}
stmt = session.prepare(sql);
for (int i = 0; i
stmt.reset();
stmt.bind(###);
...
stmt.exec();
}
} catch (std::exception const &e) {
LOG(ERROR)
}
// //关闭链接
if (session.is_open())
session.close();
}
{
//统计出表空间
session =
cppdb::session(
"mysql:user=root;password=123456;database=mysql;set_charset_name=utf8; @pool_size=1");
cppdb::statement stmt =
session.create_statement(
"select table_name,engine,ROUND(data_length/1024,2) size,table_rows from information_schema.tables where table_schema='###' and table_name='traffic'");
cppdb::result r = stmt.query();
while(r.next()){
string table_name, engine;
long size, table_rows;
r.fetch(table_name);
r.fetch(engine);
r.fetch(size);
r.fetch(table_rows);
LOG(INFO)
}
if (session.is_open())
session.close();
}
}
Isam存储测试
class benchMyisamTest: public testing::Test {
public:
static void SetUpTestCase() {
//建立对应的表结构
std::string mysql = "/usr/local/mysql/bin/mysql --default-character-set=utf8 -uroot -p123456 -D mysql -e /"source myisam.sql/"";
system(mysql.c_str());
}
static void TearDownTestCase() {
}
};
TEST_F(benchMyisamTest, 1w100) {
insertOneSession(10000, 100);
}
TEST_F(benchMyisamTest, 1w1000) {
insertOneSession(10000, 1000);
}
....
多线程存储测试
#include
//多个工作线程的处理
int thread_Num, thread_Size;
void worker(){
insertOneSession(thread_Num, thread_Size);
}
void workerThread(int ts, int count, int size){
//多线程模式下必须使用,否则mysql client库无法连接错误111
mysql_library_init(0, NULL, NULL);
thread_Num = count;
thread_Size = size;
boost::thread_group threads;
for (int i = 0; i
threads.create_thread(&worker);
}
threads.join_all();
LOG(INFO)
//这个错误好像是libmysqlclient的兼容问题 Error in my_thread_global_end(): 4 threads didn't exit
mysql_library_end();
}
TEST_F(benchMyisamTest, thread_1w100) {
workerThread(2, 10000, 100);
}
TEST_F(benchMyisamTest, thread_30w) {
workerThread(3, 100000, 1000);
}
..
其他引擎测试
和如何类似,你可以写出你自己的测试引擎
结果
如下只是我用的虚拟机平台的结果,不代表普适性
存储引擎 |
优点 |
缺点 |
MyISAM |
v 插入快 v 查询可以使用索引 |
v 存在表崩溃问题 |
ARCHIVE |
v 大量时比myisam还快 |
v 无索引 v 不能更新、删除 |
InnoDB |
v 支持事务 |
v 慢 |
TokuDB |
v 写入的高性能没有测到 |
v |
Maria |
v 和Myisam类似 v 对崩溃安全 |
v |
http://pan.baidu.com/s/1sj0cI8t 是具体的一些安装和配置不同的数据库脚本
bitsCN.com
InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version
God-level code editing software (SublimeText3)