一直以爲mysql的Memony內存引擎挺好,其餘數據庫都沒有,正好有空,因此試試。html
版本:mysql-installer-community-8.0.17.0mysql
os:windows10 SSD硬盤,本機訪問sql
簡單表,一個ID字段爲主鍵,一個字符串字段數據庫
1. Memony引擎windows
單條插入10000條耗時18s,批量事務提交插入10000條耗時18s。測試
2. Myisam引擎ui
單條插入10000條耗時19s,批量事務提交插入10000條耗時19s。this
3. InnoDB引擎orm
單條插入10000條耗時40s,批量事務提交插入10000條耗時2s。htm
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不是過高