mysql不同版本和存储引擎选型的验证_MySQL
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
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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics











The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

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.

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

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
