Insert performance - seems really really really slow
643400Jun 11 2008 — edited Aug 11 2008Ok, another one for you all.
string createdbcmd =
"CREATE TABLE DOCUMENT " +
"(" +
" doc_id CHAR(36)," +
" doc_name VARCHAR2(512)," +
" content_status VARCHAR2(256)," +
" current_version NUMBER(10,0) DEFAULT 0 NOT NULL," +
" CONSTRAINT PK_document PRIMARY KEY(doc_name)" +
")";
I have C# code that inserts 1000 rows into a brand new table (the one defined above) using the .Net provider.
string insertdbcmd =
"INSERT INTO document (DOC_NAME) values (?)";
OracleConnection conn = ConnectDB();
conn.Open();
IDbCommand cmd = conn.CreateCommand();
cmd = conn.CreateCommand();
cmd.CommandText = insertdbcmd;
for (int i = 0; i < 1000; i++)
{
cmd.Parameters.Clear();
cmd.Parameters.Add(new OracleParameter("param1", Guid.NewGuid().ToString()));
cmd.ExecuteNonQuery();
}
conn.Close();
This loop takes 55 seconds to execute. The equivalent insert command run against a Firebird DB configured as an embedded DB takes 2 seconds. I find it hard to believe there can be that huge or a performance disparity. Is there something we are missing or is the insertion performance that slow? Note data retrieval (SELECT DOC_NAME FROM DOCUMENT ORDER BY DOC_NAME) seems to perform fine - .06 seconds.