473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Discussion: Typet DataSets vs Untyped DataSets

Hi,

I wonder about performerce comparision between these two
types of DataSets. Are benefits of typed DataSets enought
to beat speed of untyped ones?
Or it doesn't matter?
What do you think?

Przemo
Nov 21 '05 #1
7 1782
Przemo,

The typed dataset is an untyped dataset that is encapseled in another class.
Why would there be a speed difference?

Cor

I wonder about performerce comparision between these two
types of DataSets. Are benefits of typed DataSets enought
to beat speed of untyped ones?
Or it doesn't matter?
What do you think?

Przemo

Nov 21 '05 #2
Przemo,
Using a typed dataset will probably be faster then using an untyped dataset.

The reason being is the typed dataset uses a DataColumn when indexing into
the DataRow.Item property. Most untyped dataset code will use either an
Integer or the field name when indexing into the DataRow.Item property.

David Sceppa's book "Microsoft ADO.NET - Core Reference" from MS Press,
explains why & how the typed dataset is faster, he also explains why & how
you can use the same techniques in your own untyped datasets.

I recommend purchasing Sceppa's book as it is a good tutorial on ADO.NET
as well as a good desk reference once you know ADO.NET.

Hope this helps
Jay

"Przemo" <p.**********@deltatrans.pl> wrote in message
news:41****************************@phx.gbl...
Hi,

I wonder about performerce comparision between these two
types of DataSets. Are benefits of typed DataSets enought
to beat speed of untyped ones?
Or it doesn't matter?
What do you think?

Przemo

Nov 21 '05 #3
Jay,
Using a typed dataset will probably be faster then using an untyped dataset.

Why when I use exactly the same code as is use to make a typed dataset to
access my untyped dataset directly.

I can understand your statetement, when you say: "a typed dataset is mostly
made with more eye for efficiency". However when it is as my first sentence,
I don't see it.

Cor
Nov 21 '05 #4
Cor,
Have you read Sceppa's book? Do you have Sceppa's book? I would strongly
recommend you purchase & read Sceppa's book!

Read chapter 9 "Working with strongly Typed DataSet objects", specifically
page 391-392 "Run-Time Benefits", as of the writing of the edition I have,
Sceppa found typed dataSets to be almost twice as fast as untyped datasets,
what the actual difference is I'm not sure as the edition I have his
statement was based on a beta version of .NET.

As I explained in my post, Typed DataSets use DataRow.Item(DataColumn),
which is faster then either DataRow.Item(String) or DataRow.Item(Integer). I
suspect the later two are implemented in terms of the first one, thus
explaining the difference.

Hope this helps
Jay

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Ow**************@TK2MSFTNGP10.phx.gbl...
Jay,
Using a typed dataset will probably be faster then using an untyped

dataset.

Why when I use exactly the same code as is use to make a typed dataset to
access my untyped dataset directly.

I can understand your statetement, when you say: "a typed dataset is
mostly
made with more eye for efficiency". However when it is as my first
sentence,
I don't see it.

Cor

Nov 21 '05 #5
Cor,
Seeing as Sceppa's statement was based on a beta I put together the
following test, hopefully I did it right ;-)
Public Class DataSetTiming

Private Delegate Sub Test(ByVal row As DataRow, ByVal column As
DataColumn)

Declare Function QueryPerformanceCounter Lib "Kernel32" (ByRef X As
Long) As Short
Declare Function QueryPerformanceFrequency Lib "Kernel32" (ByRef X As
Long) As Short

Public Shared Sub Main()
Dim table As DataTable = CreateTable()
PopulateTable(table)
For index As Integer = 1 To 10
Debug.WriteLine(index, "test")
Debug.Indent()
RunTest("Integer", AddressOf IntegerIndex, table)
RunTest("String", AddressOf StringIndex, table)
RunTest("Column", AddressOf ColumnIndex, table)
Debug.Unindent()
Debug.WriteLine(Nothing)
Next
End Sub

Private Shared Function CreateTable() As DataTable
Dim table As New DataTable("Test")
table.Columns.Add("id", GetType(Integer))
table.Columns.Add("name", GetType(String))
table.Columns.Add("value", GetType(Decimal))
With table.Columns("id")
.AutoIncrement = True
.AutoIncrementSeed = -1
.AutoIncrementStep = -1
End With
Return table
End Function

Private Shared Sub PopulateTable(ByVal table As DataTable)
Dim rand As New Random
For index As Integer = 0 To 100000
table.Rows.Add(New Object() {Nothing, String.Format("V{0}",
index), rand.Next(1, 1000)})
Next
End Sub

Private Shared Sub RunTest(ByVal category As String, ByVal test As Test,
ByVal table As DataTable)
Dim start, finish, frequency As Long
QueryPerformanceCounter(start)
Dim column As DataColumn = table.Columns("value")
For Each row As DataRow In table.Rows
test(row, column)
Next
QueryPerformanceCounter(finish)
QueryPerformanceFrequency(frequency)
Debug.WriteLine((finish - start) / frequency, category)
End Sub

Private Shared Sub IntegerIndex(ByVal row As DataRow, ByVal column As
DataColumn)
row(2) = DirectCast(row(2), Decimal) * 1.1D
End Sub

Private Shared Sub StringIndex(ByVal row As DataRow, ByVal column As
DataColumn)
row("value") = DirectCast(row("value"), Decimal) * 1.1D
End Sub

Private Shared Sub ColumnIndex(ByVal row As DataRow, ByVal column As
DataColumn)
row(column) = DirectCast(row(column), Decimal) * 1.1D
End Sub

End Class

Running 10 sets I get the following:

test: 1
Integer: 1.3314144674812
String: 1.29888407604877
Column: 1.06492529078416

test: 2
Integer: 1.10235853998204
String: 1.32747067015501
Column: 1.0537758290509

test: 3
Integer: 1.0954998470476
String: 1.33955460819741
Column: 1.06967896757828

test: 4
Integer: 1.12571150802686
String: 1.33948337009313
Column: 1.05996264888415

test: 5
Integer: 1.15852098520901
String: 1.32627694301929
Column: 1.066469621139

test: 6
Integer: 1.15292222894251
String: 1.36355626203889
Column: 1.1006843048488

test: 7
Integer: 1.14156352273823
String: 1.33735544601339
Column: 1.08128267698828

test: 8
Integer: 1.14533830416994
String: 1.33989096379568
Column: 1.08176709609741

test: 9
Integer: 1.13144491827872
String: 1.38126968651044
Column: 1.11549261149113

test: 10
Integer: 1.17510465715615
String: 1.35280657178496
Column: 1.10689766436796

Which shows that indexing DataRow by DataColumn is quicker, however not by
much. indexing DataRow by String is clearly slower...

Hope this helps
Jay
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Ow**************@TK2MSFTNGP10.phx.gbl...
Jay,
Using a typed dataset will probably be faster then using an untyped

dataset.

Why when I use exactly the same code as is use to make a typed dataset to
access my untyped dataset directly.

I can understand your statetement, when you say: "a typed dataset is
mostly
made with more eye for efficiency". However when it is as my first
sentence,
I don't see it.

Cor

Nov 21 '05 #6
Jay,

My point is that everything you create in a typed datases you can do with an
untyped dataset. When you say that this is a wrong statement of me, than I
can agree with you even without one single piece of code.

Another question: is that QueryPerformanceCounter more accurate than the
environment.ticks? (I can look it up however when you say so it is for me in
this case).

It is by the way an interesting piece of code you made, I will take some
time today to evaluate it completly :-)

Thanks,

Cor
Cor,
Seeing as Sceppa's statement was based on a beta I put together the
following test, hopefully I did it right ;-)
Public Class DataSetTiming

Private Delegate Sub Test(ByVal row As DataRow, ByVal column As
DataColumn)

Declare Function QueryPerformanceCounter Lib "Kernel32" (ByRef X As
Long) As Short
Declare Function QueryPerformanceFrequency Lib "Kernel32" (ByRef X As
Long) As Short

Public Shared Sub Main()
Dim table As DataTable = CreateTable()
PopulateTable(table)
For index As Integer = 1 To 10
Debug.WriteLine(index, "test")
Debug.Indent()
RunTest("Integer", AddressOf IntegerIndex, table)
RunTest("String", AddressOf StringIndex, table)
RunTest("Column", AddressOf ColumnIndex, table)
Debug.Unindent()
Debug.WriteLine(Nothing)
Next
End Sub

Private Shared Function CreateTable() As DataTable
Dim table As New DataTable("Test")
table.Columns.Add("id", GetType(Integer))
table.Columns.Add("name", GetType(String))
table.Columns.Add("value", GetType(Decimal))
With table.Columns("id")
.AutoIncrement = True
.AutoIncrementSeed = -1
.AutoIncrementStep = -1
End With
Return table
End Function

Private Shared Sub PopulateTable(ByVal table As DataTable)
Dim rand As New Random
For index As Integer = 0 To 100000
table.Rows.Add(New Object() {Nothing, String.Format("V{0}",
index), rand.Next(1, 1000)})
Next
End Sub

Private Shared Sub RunTest(ByVal category As String, ByVal test As Test, ByVal table As DataTable)
Dim start, finish, frequency As Long
QueryPerformanceCounter(start)
Dim column As DataColumn = table.Columns("value")
For Each row As DataRow In table.Rows
test(row, column)
Next
QueryPerformanceCounter(finish)
QueryPerformanceFrequency(frequency)
Debug.WriteLine((finish - start) / frequency, category)
End Sub

Private Shared Sub IntegerIndex(ByVal row As DataRow, ByVal column As
DataColumn)
row(2) = DirectCast(row(2), Decimal) * 1.1D
End Sub

Private Shared Sub StringIndex(ByVal row As DataRow, ByVal column As
DataColumn)
row("value") = DirectCast(row("value"), Decimal) * 1.1D
End Sub

Private Shared Sub ColumnIndex(ByVal row As DataRow, ByVal column As
DataColumn)
row(column) = DirectCast(row(column), Decimal) * 1.1D
End Sub

End Class

Running 10 sets I get the following:

test: 1
Integer: 1.3314144674812
String: 1.29888407604877
Column: 1.06492529078416

test: 2
Integer: 1.10235853998204
String: 1.32747067015501
Column: 1.0537758290509

test: 3
Integer: 1.0954998470476
String: 1.33955460819741
Column: 1.06967896757828

test: 4
Integer: 1.12571150802686
String: 1.33948337009313
Column: 1.05996264888415

test: 5
Integer: 1.15852098520901
String: 1.32627694301929
Column: 1.066469621139

test: 6
Integer: 1.15292222894251
String: 1.36355626203889
Column: 1.1006843048488

test: 7
Integer: 1.14156352273823
String: 1.33735544601339
Column: 1.08128267698828

test: 8
Integer: 1.14533830416994
String: 1.33989096379568
Column: 1.08176709609741

test: 9
Integer: 1.13144491827872
String: 1.38126968651044
Column: 1.11549261149113

test: 10
Integer: 1.17510465715615
String: 1.35280657178496
Column: 1.10689766436796

Which shows that indexing DataRow by DataColumn is quicker, however not by
much. indexing DataRow by String is clearly slower...

Hope this helps
Jay
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Ow**************@TK2MSFTNGP10.phx.gbl...
Jay,
Using a typed dataset will probably be faster then using an untyped

dataset.

Why when I use exactly the same code as is use to make a typed dataset to access my untyped dataset directly.

I can understand your statetement, when you say: "a typed dataset is
mostly
made with more eye for efficiency". However when it is as my first
sentence,
I don't see it.

Cor


Nov 21 '05 #7
Cor,
Please read my original post again! Read the entire post, specifically the
second paragraph!

<quote>
The reason being is the typed dataset uses a DataColumn when indexing into
the DataRow.Item property. Most untyped dataset code will use either an
Integer or the field name when indexing into the DataRow.Item property.
</quote>

Notice that I state why the typed dataset is faster (which you are free to
use) and why most untyped code is slower (which again you are free not to
use).

Again Sceppa explains how to use the same techniques as the typed dataset!

Another question: is that QueryPerformanceCounter more accurate than the
environment.ticks? (I can look it up however when you say so it is for me
in
this case).
http://support.microsoft.com/default...b;en-us;306978

Enivonment.TickCount is "the amount of time in milliseconds that has passed
since the last time the computer was started". My understanding
Environment.TickCount is calling the Win32 GetTickCount API.

The QueryPerformanceCounter is at the same resolution as the Performance
Counter classes, (nanosecond or higher).

There is also DateTime (DateTime.Ticks) which is "the number of
100-nanosecond intervals that have elapsed..."

VS.NET 2005 (aka Whidbey due out in 2005) will have a stopwatch object that
appears to use either QueryPerformanceCounter or DateTime.

http://lab.msdn.microsoft.com/librar..._Stopwatch.asp

Hope this helps
Jay

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl... Jay,

My point is that everything you create in a typed datases you can do with
an
untyped dataset. When you say that this is a wrong statement of me, than I
can agree with you even without one single piece of code.

Another question: is that QueryPerformanceCounter more accurate than the
environment.ticks? (I can look it up however when you say so it is for me
in
this case).

It is by the way an interesting piece of code you made, I will take some
time today to evaluate it completly :-)

Thanks,

Cor
Cor,
Seeing as Sceppa's statement was based on a beta I put together the
following test, hopefully I did it right ;-)
Public Class DataSetTiming

Private Delegate Sub Test(ByVal row As DataRow, ByVal column As
DataColumn)

Declare Function QueryPerformanceCounter Lib "Kernel32" (ByRef X As
Long) As Short
Declare Function QueryPerformanceFrequency Lib "Kernel32" (ByRef X As
Long) As Short

Public Shared Sub Main()
Dim table As DataTable = CreateTable()
PopulateTable(table)
For index As Integer = 1 To 10
Debug.WriteLine(index, "test")
Debug.Indent()
RunTest("Integer", AddressOf IntegerIndex, table)
RunTest("String", AddressOf StringIndex, table)
RunTest("Column", AddressOf ColumnIndex, table)
Debug.Unindent()
Debug.WriteLine(Nothing)
Next
End Sub

Private Shared Function CreateTable() As DataTable
Dim table As New DataTable("Test")
table.Columns.Add("id", GetType(Integer))
table.Columns.Add("name", GetType(String))
table.Columns.Add("value", GetType(Decimal))
With table.Columns("id")
.AutoIncrement = True
.AutoIncrementSeed = -1
.AutoIncrementStep = -1
End With
Return table
End Function

Private Shared Sub PopulateTable(ByVal table As DataTable)
Dim rand As New Random
For index As Integer = 0 To 100000
table.Rows.Add(New Object() {Nothing, String.Format("V{0}",
index), rand.Next(1, 1000)})
Next
End Sub

Private Shared Sub RunTest(ByVal category As String, ByVal test As

Test,
ByVal table As DataTable)
Dim start, finish, frequency As Long
QueryPerformanceCounter(start)
Dim column As DataColumn = table.Columns("value")
For Each row As DataRow In table.Rows
test(row, column)
Next
QueryPerformanceCounter(finish)
QueryPerformanceFrequency(frequency)
Debug.WriteLine((finish - start) / frequency, category)
End Sub

Private Shared Sub IntegerIndex(ByVal row As DataRow, ByVal column As
DataColumn)
row(2) = DirectCast(row(2), Decimal) * 1.1D
End Sub

Private Shared Sub StringIndex(ByVal row As DataRow, ByVal column As
DataColumn)
row("value") = DirectCast(row("value"), Decimal) * 1.1D
End Sub

Private Shared Sub ColumnIndex(ByVal row As DataRow, ByVal column As
DataColumn)
row(column) = DirectCast(row(column), Decimal) * 1.1D
End Sub

End Class

Running 10 sets I get the following:

test: 1
Integer: 1.3314144674812
String: 1.29888407604877
Column: 1.06492529078416

test: 2
Integer: 1.10235853998204
String: 1.32747067015501
Column: 1.0537758290509

test: 3
Integer: 1.0954998470476
String: 1.33955460819741
Column: 1.06967896757828

test: 4
Integer: 1.12571150802686
String: 1.33948337009313
Column: 1.05996264888415

test: 5
Integer: 1.15852098520901
String: 1.32627694301929
Column: 1.066469621139

test: 6
Integer: 1.15292222894251
String: 1.36355626203889
Column: 1.1006843048488

test: 7
Integer: 1.14156352273823
String: 1.33735544601339
Column: 1.08128267698828

test: 8
Integer: 1.14533830416994
String: 1.33989096379568
Column: 1.08176709609741

test: 9
Integer: 1.13144491827872
String: 1.38126968651044
Column: 1.11549261149113

test: 10
Integer: 1.17510465715615
String: 1.35280657178496
Column: 1.10689766436796

Which shows that indexing DataRow by DataColumn is quicker, however not
by
much. indexing DataRow by String is clearly slower...

Hope this helps
Jay
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Ow**************@TK2MSFTNGP10.phx.gbl...
> Jay,
>
>> Using a typed dataset will probably be faster then using an untyped
> dataset.
>>
> Why when I use exactly the same code as is use to make a typed dataset to > access my untyped dataset directly.
>
> I can understand your statetement, when you say: "a typed dataset is
> mostly
> made with more eye for efficiency". However when it is as my first
> sentence,
> I don't see it.
>
> Cor
>
>



Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: William Ryan | last post by:
At the risk of sounding like a Big 5 consultant, "It depends". 1) Strongly typed datasets rock, they are faster than untyped, use intellisense... but your reason for wanting to use them is...
2
by: Fresh Air Rider | last post by:
Could anyone please provide a code snippet demonstrating how to use the Repeater control in conjunction with the PagedDataSource class and a Strongly Typed Dataset ? I get an error informing me...
1
by: Fresh Air Rider | last post by:
Hi Fellow Dotnetters Could anyone please provide a code snippet demonstrating how to use the Repeater control in conjunction with the PagedDataSource class and a Strongly Typed Dataset ? I...
0
by: pabloch2 | last post by:
Why the data access layer should use untyped datasets? Is this applicable to the 3 layered architecture in general or is it related with the implementation in .net? Can someone recommend me a...
4
by: Ronald S. Cook | last post by:
I've always used untyped datasets. In a Microsoft course, it walks through creating typed datasets and harps on the benefits. It has you drag all these things around ..wizard, wizard, wizard......
1
by: Paez | last post by:
Hi There. This post is a extension of thread "Serialize or not to Serialize", on 5 of December of 2006. The reason why my teacher insists that a WS cannot return a Dataset is due to low rate...
0
by: vrushalik | last post by:
Hi, i want to know pros and cons of both Typed and Untyped dataset in detail. can we customize untyped dataset? What is benefit of Typed dataset? is there significant difference between...
0
by: Rachana | last post by:
Hi, I have understood Data Sets but what is meant by typed/untyped/ strongly typed datasets. Can any one explain me or suggest any site/ article, to get these concepts (and their ...
4
by: Rachana | last post by:
Hi, I have understood Data Sets but what is meant by typed/untyped/ strongly typed datasets. Can any one explain me or suggest any site/ article, to get these concepts (and their ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.