一直觉得mysql的Memony内存引擎挺好,其他数据库都没有,正好有空,所以试试。
版本:mysql-installer-community-8.0.17.0
os:windows10 SSD硬盘,本机访问
简单表,一个ID字段为主键,一个字符串字段
1. Memony引擎
单条插入10000条耗时18s,批量事务提交插入10000条耗时18s。
2. Myisam引擎
单条插入10000条耗时19s,批量事务提交插入10000条耗时19s。
3. InnoDB引擎
单条插入10000条耗时40s,批量事务提交插入10000条耗时2s。
private void button1_Click(object sender, EventArgs e) { //删除 DateTime d = DateTime.Now; string sql = "delete from " + this.textBox1.Text; MySqlConnection cn = new MySqlConnection(this.connstring); cn.Open(); MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(sql, cn); cmd.ExecuteNonQuery(); cn.Close(); this.textBox2.Text = (DateTime.Now - d).TotalMilliseconds.ToString(); } private void button2_Click(object sender, EventArgs e) { //单条增加 DateTime d = DateTime.Now; MySqlConnection cn = new MySqlConnection(this.connstring); cn.Open(); string sql = "insert into " + this.textBox1.Text + "(a,v) values({0}, '{1}')"; for (int m = 0; m < 10000; m++) { string s = string.Format(sql, m, System.Guid.NewGuid().ToString() + "在"); MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(s, cn); cmd.ExecuteNonQuery(); } cn.Close(); this.textBox2.Text = (DateTime.Now - d).TotalMilliseconds.ToString(); } private void button3_Click(object sender, EventArgs e) { //单条增加 DateTime d = DateTime.Now; MySqlConnection cn = new MySqlConnection(this.connstring); cn.Open(); MySqlTransaction tran = cn.BeginTransaction(); string sql = "insert into " + this.textBox1.Text + "(a,v) values({0}, '{1}')"; for (int m = 0; m < 10000; m++) { string s = string.Format(sql, m, System.Guid.NewGuid().ToString() + "在"); MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(s, cn); cmd.Transaction = tran; cmd.ExecuteNonQuery(); } tran.Commit(); cn.Close(); this.textBox2.Text = (DateTime.Now - d).TotalMilliseconds.ToString(); } private void button4_Click(object sender, EventArgs e) { //查询 MySqlDataAdapter da = new MySqlDataAdapter("select * from " + this.textBox1.Text, this.connstring); DataSet ds = new DataSet(); da.Fill(ds, "t"); this.dataGridView1.DataSource = ds.Tables[0].DefaultView; }
下面N多年前的测试,可做对比:
https://www.cnblogs.com/81/archive/2009/07/31/1535694.html
https://www.cnblogs.com/81/archive/2008/12/06/1348896.html
感觉mysql不是太高