Topaz Filer: if you use e-mail for business, we can save you money and decrease your risk.
Powerbuilder faster than c# ado.net?
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.performance.


news.microsoft.com
Someone please tell me that I'm doing something drastically wrong. I am in
the throws of convincing my senior management that we should switch from
powerbuilder to c# and .net. So I wrote a little test windows forms app that
creates 1000 rows in a dataset and updates a sql server 2000 table with the
1000 rows via a DataAdapter.update. I wrote the same app in powerbuilder 6.5
and did the same thing (create 1000 rows and update the same sql 2000 db
table). After numerous tests, the powerbuilder application seems to crush
the c# app performance. The powerbuilder app performs the inserts in an avg
of 4 -7 seconds. The C# app performs the inserts at an avg of 15 - 30
seconds.
This really doesn't help my case for switching to C#. I even went as far as
using stored procs for the c# inserts and not in the pb app.
The sql profiler shows an average duration of 10 for each c# insert and 0
for the comparable powerbuilder inserts (yes it is actually doing the
inserts).
If anyone can shed some light as to what the c# bottleneck may be I would
really appreciate it.

p.s. I realize that there are other methods for performing bulk inserts in
..net like using the entire dataset in an xml document as input into a stored
proc, but I don't think that would result in a fair comparison... we
wouldn't want to "Cook" a benchmark now would we.

Thanks,
Brent.

Reply to this message...
Vote that this is a GOOD answer...
 
Auto-following on Twitter
Ubuntu and XP on one “desktop”
 
    
Bob Grommes
I think you'd need to post your C# code for anyone to give you an
intelligent idea on this.

--Bob

"news.microsoft.com" <Click here to reveal e-mail address> wrote in message
news:e86bYK3uCHA.616@TK2MSFTNGP11...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer...
 
Outlook interop - stopping user properties appearing on Outlook message print
Seriously, why is “cut and paste” majorly newsworthy???
 
    
Brent Kurdydyk
Here is the code in a nutshell with a little background. The table I am
updating is on a SQL 2000 server , it contains 3 columns ( the pk which is
an identity int column, and 2 other int columns).
I am using a strongly typed dataset (dsPerfTestData.perf_test) and a stored
procedure to perform the inserts, here is an excerpt from the code:
public void PerfTest()
{
int Rows = 999;
this.dsPerfTestData.perf_test.BeginLoadData();

DateTime StartTime = DateTime.Now;

for(int row = 0; row <= Rows; row +=1)

{

DSPerfTest.perf_testRow prow =
this.dsPerfTestData.perf_test.Newperf_testRow();

prow.perf_key=0;

prow.perf_count = row;

if (row > 1)

{

prow.perf_running_total = row +
this.dsPerfTestData.perf_test[row -1].perf_running_total;

}

else

{

prow.perf_running_total = row;

}

this.dsPerfTestData.perf_test.Addperf_testRow(prow);

}

this.dsPerfTestData.perf_test.EndLoadData();

this.sqlConnectionTestDb.Open();

this.sqlDataAdapter1.Update(this.dsPerfTestData,"perf_test");

this.sqlConnectionTestDb.Close();

}

"Bob Grommes" <Click here to reveal e-mail address> wrote in message
news:Ohkk4J5uCHA.1244@TK2MSFTNGP12...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Joao.Cardoso
GOOD ANSWER
Try using a connection and a comand object only to insert objects.

Do not use Typed datasets. You dont need it to update data.

Create a new SQLClient.SQLConnection object, create a
SQLClient.SQLCommand and a SQLClient.SQLTransaction

Then use Command, add the SP parameters and to call your SP with the
command object.

Use only one transaction, and commit it at the end. Or, if you are not
using transactions on the other system, dont use it whatsoever.

Mind that SQLClient object is pooled. The first time you open the
connection it can take 2 ou even 3 x more time than on the second
time. Inserting 1000 record should be quite fast.

Use a timer to test the inserts but start counting for both examples
after the connection is open.

Typed datasets, commandbuilders, etc... are good tools for making
developlment easier... but as everything in life, making it easy is
not in any way the fastest and best way to do it in most cases.

Mind also that the first time you run a StoredProc, SQL compiles it...
so this is also an overhead that you must remove from the test by
runing the SP at least once after any change you make on it.

Best regards

João Cardoso

On Tue, 14 Jan 2003 09:52:17 -0600, "Brent Kurdydyk"
<Click here to reveal e-mail address> wrote:

Joao.Cardoso
=============================================
[LusoCoders]- Portuguese Coders
Click here to reveal e-mail address
=============================================
Reply to this message...
Vote that this is a GOOD answer... (1 vote from another user already)
 
 
    
Bruce L-C
GOOD ANSWER
When does Powerbuilder test app connect to the database? The timing in the
C# is including the time to connect to the database. Just making sure you
are comparing apples to apples.

I bet if you look at what Powerbuilder is doing that it is wrapping the
transaction. What you are doing now in dotnet is a transaction per row to
insert. So, 1,000 transactions for 1000 statements. I would wrap this either
100 statements per transaction or even do the whole 1000 statements in a
single transaction. There is nothing that says you have to use the
dataadapter update method. You can get all new records in the dataset (there
is a method to do this) then walk through that dataset (data table). Start a
transaction, execute each statement and then end transaction. There is no
way inserting 1000 records as simple as this should take so long.

Bruce L-C

"Brent Kurdydyk" <Click here to reveal e-mail address> wrote in message
news:OXHNgT#uCHA.2596@TK2MSFTNGP12...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (1 vote from another user already)
 
 
    
Barry Gervin
I'm certain it's not doing a transaction per row. It would be doing an
implicit commit on the close of the conneciton.

Barry Gervin
www.ObjectSharp.com/Barry

"Bruce L-C" <Click here to reveal e-mail address> wrote in message
news:eTTep7$uCHA.2280@TK2MSFTNGP11...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Ben Kloosterman
GOOD ANSWER
Your not comparing apples to apples ... Datasets are in memory data copies ,
you should stick to datareaders if you want to compare to powerbuilder. Is
like comparing a 2 tier system to a 3 tier system eg the 2 Tier system will
always be faster , but once you put some load on it and use caching things
start to change. .

In a real world environment you would send the update to the dataset which
can respond to the user immediately and then send it to the DB or middleTier
in the background ( and alert the user if it fails) - this is the type of
scenario Datasets are designed for . Datasets are an extra layer and can
not compete with direct access. In a few documents I have seen it states if
you want good update performance use XML (remember Datasets are stored as
XML ) or send the data via SQL command direct . For a fast and dirty app
have a look at the nile bookshop - no Datasets are used.

My thinking goes something like this use Datasets for you winforms and apps
, but do not use them for batch updates and deletes.

Ben

"Brent Kurdydyk" <Click here to reveal e-mail address> wrote in message
news:OXHNgT#uCHA.2596@TK2MSFTNGP12...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (3 votes from other users already)
 
 
    
Barry Gervin
GOOD ANSWER
PowerBuilder DataWindows are also in memory data copies just like .NET
DataSets. .... only they have been around since the early 90's. His example
code is also 2 tier as is I suspect the PB app. Just because you go through
a data set doesn't insert an extra tier and what we are talking about with
PB is exactly the same architecture as a .NET DataSet.

Given the fact that we are using the SqlConnection & DataAdapter we are
talking advantaged of Sql Server's Tabular Data Stream (TDS) which should be
faster than the equivalent interface in PB. (I don't think it's been updated
to support TDS).

Brent - what version of Sql Server are you using?

Regards,

Barry Gervin
www.ObjectSharp.com/Barry

"Ben Kloosterman" <Click here to reveal e-mail address> wrote in message
news:upvSIy7vCHA.2352@TK2MSFTNGP09...
> Your not comparing apples to apples ... Datasets are in memory data copies
,
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (1 vote from another user already)
 
 
    
Dave Fish
I'm not really surprised by that. You didn't say which database driver you used with PB 6.5 but I'll assume it was the native DBLIB driver that comes with PowerBuilder 6.5. I think you will be hard pressed to beat PB's performance with C# and ADO .NET.

If you want to find out if it is the driver, you can download an evaluation version of PowerBuilder 10 at www.sybase.com/powerbuilder and try your application using the ADO .NET driver that comes with PB 10. It uses OLE DB under the covers so you can try it with that as well as ODBC. The native DBLIB driver isn't supported in PB 10 anymore because PowerBuilder 10 is Unicode and it wasn't worth the effort to convert the native driver when MS recommends OLEDB and ADO .NET for accessing SQL Server.

I should mention that with PowerBuilder 11, developers will be able to compile their PB applications to .NET WinForm or WebForm applications. PB 11 is slated for release in the 2nd half of 2005.

You might also want to try out DataWindow .NET (www.sybase.com/datawindow.net) and compare its performance to the C# code you wrote.

DataWindow technology may have been around for a while but that doesn't mean it shouldn't be considered for use in new applications. Sybase continues to fine tune the technology and you might be surprised at what you can do with PowerBuilder 10 compared to PowerBuilder 6.5.

Regards,
Dave Fish
Sybase
Reply to this message...
Vote that this is a GOOD answer...
 
 
 
System.Data.Common.DataAdapter
System.Data.DataSet
System.Data.SqlClient.SqlConnection
System.DateTime




Ad
BootFX
Reliable and powerful .NET application framework.
Recession Busting Bespoke Software
Get through the recession by investing in bespoke software to decrease costs and create commercial opportunities.
Other DN247 Network Sites
.NET 247
SQL Server Wins
Old Skool Developer
 
Copyright © AMX Software Ltd 2008-2009. Portions copyright © Matthew Baxter-Reynolds 2001-2009. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - .NET 247 is a member of the DN247 Network - 4.0.30129.1734