Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle and Dotnet

Re: Oracle and Dotnet

From: Holger Baer <holger.baer_at_science-computing.de>
Date: Fri, 03 Jun 2005 09:44:15 +0200
Message-ID: <d7p1og$pej$1@news.BelWue.DE>


Larry wrote:
> Jim Kennedy wrote:
>
>
> Is it possible there are some inefficiencies in the code. Sure.
> Do I think they are so bad to drop the rate from the 10,000 per second I
> get with PL/SQL on SQLplus down to 40 per second with ODP.NET.
>
> I doubt it.
>
> I only open the connection once.
> I'm not committing after each insert, I wait til the loop is finished.

So you think. But .NET is autocommiting as every junk was that excreated by MS. (And the reason behind this is that MS SQL Server is not very good in long running transactions). Even JDBC suffers the same problem (because most Java guys are not much better when it comes to databases).

So search the .Net documentation how to turn off autocommit, and you'll be fine.

> I'm not using binding because I insert the same fixed SQL statement each
> time.
>
> Are there some inefficiencies...maybe...but geez, 40 inserts per second?

You suffer the same problem that many developers suffer. You start out with a small benchmark, and instead of trying to learn something out of it (namely how to use Oracle correctly in the first place) you're prepared to blame anybody else. A database is not a bit bucket and code that runs on one RDBMS will not necessarily run well on another. ANSI SQL is a formal description of the SQLanguage, however, it's implementation varies from RDBMS to RDBMS.

To simulate what the .NET code actually does, you can run the following test:   declare
   2 l_txt varchar2(20);
   3 begin
   4 for i in 1..10000 loop

   5      l_txt := lpad (to_char(i), 20, '*');
   6      execute immediate 'insert into demo values (''' || l_txt  ||''')';
   7      commit;

   8 end loop;
   9 end;
  10 /

The timing will not be the same, but it will get you in the right direction.

Now how to fix this?
Try this:
> //create the command and assign the connection to it
> OracleCommand cmd = new OracleCommand();
> cmd.Connection = con;
>
> //create the SQL, no variables, no bindings to worry about
> string SQL = "insert into test values ('1')";
> cmd.CommandText = SQL;
>

       OracleTransation TransX = con.BeginTransaction();
       cmd.Transaction = TransX;

> //do my loop
> for (int x = 1; x<1000; x++)
> {
> cmd.ExecuteNonQuery();
> }
TransX.Commit();

I'm not a .NET developer. But http://www.datadirect.com/developer/net/dot_net_optimizing/index.ssp seem to know what they are talking about.

HTH
Holger Received on Fri Jun 03 2005 - 02:44:15 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US