MySQL Forums
Forum List  »  Performance

1000 insert 24063 ms?
Posted by: Guangpin Liu
Date: May 11, 2005 01:19PM

It this true or my config is wrong? SQL only use 2703 ms to finish same work. How can I use mySQL instead of SQL? Please help me to make performance improvement, thanks ahead, the following is the code:

private void Button1_Click(object sender, System.EventArgs e)
{
String strConn = @"DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost;
DATABASE=MySQLInstance; UID=root; PASSWORD=abc; port=3306; OPTION=3";

OdbcConnection oConn = new OdbcConnection(strConn);
OdbcCommand oCmd = new OdbcCommand();
oConn.Open();
long startTime = Environment.TickCount;
for (int i=1; i<=1000; i++)
{

String strSQL = "insert into CodeLookup(CodeGroup, CodeValue, CodeName, Description) values ('CodeGroup', 1, 'CodeName', '" + i.ToString() + "')";
oCmd.Connection = oConn;
oCmd.CommandText = strSQL;
oCmd.ExecuteNonQuery();

}
long endTime = Environment.TickCount;
TextBox1.Text += " " + (endTime - startTime);
oConn.Close();
}


private void Button2_Click(object sender, System.EventArgs e)
{
String strConn = @"Data Source=(local)\SQLDB; Initial Catalog=TESTDB; User=TestUser; PASSWORD=abc; ";
SqlConnection oConn = new SqlConnection(strConn);
SqlCommand oCmd = new SqlCommand();
oConn.Open();

long startTime = Environment.TickCount;
for (int i=1; i<=1000; i++)
{
String strSQL = "insert into CodeLookup(CodeGroup, CodeValue, CodeName, Description) values ('CodeGroup', 1, 'CodeName', '" + i.ToString() + "')";

oCmd.Connection = oConn;
oCmd.CommandText = strSQL;

oCmd.ExecuteNonQuery();


}

long endTime = Environment.TickCount;
TextBox1.Text += " " + (endTime - startTime);
oConn.Close();
}

Options: ReplyQuote


Subject
Views
Written By
Posted
1000 insert 24063 ms?
2373
May 11, 2005 01:19PM
1604
May 15, 2005 10:40AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.