473,770 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.Data.Dat aTable Performance Issue

Hello,

We are using DataTable to store our data that we retrieve
from SQL because it provides us with ROW/COLUMN concept.
Due to DataTable been memory hungary we are finding that
at least 40MB of memory is been created every second which
means the GC is concently running. We want to use
something else that is not memory hungary and will give us
the ROW/COLUMN concept (ie Multi-dimension Arrays).

My question is that, is there any other .Net object that
is light weight which will give me the ROW/COLUMN concept.
Please also note that we do want to store data in the
COLUMNS with different datatypes. For example I could have
2 columns. Column 1 is a string and Column 2 is a double.

Thanks,
Nov 15 '05 #1
8 15276
Hello,

You could try using a multidimentoial array:

object[,,] oArr = new object[ 20, 4 ];

Then you can stick anything you want in any cell, but be
aware that some boxing and unboxing will occur.

You could create a typed multidementiona l array:

object[] rs = new object[4]; // 4 equals the column count
rs[0] = new int[20]; // 20 equals the row count
rs[1] = new string[20];
rs[2] = new double[20];
rs[3] = new bool[20];

double tmp = ((double[])rs[2])[15]; // 3rd column of 16th
row

or if you are reading from a database you could use a
DataReader. ( Its forward only and read only )

Hope this helps.

Jeff
-----Original Message-----
Hello,

We are using DataTable to store our data that we retrievefrom SQL because it provides us with ROW/COLUMN concept.
Due to DataTable been memory hungary we are finding that
at least 40MB of memory is been created every second whichmeans the GC is concently running. We want to use
something else that is not memory hungary and will give usthe ROW/COLUMN concept (ie Multi-dimension Arrays).

My question is that, is there any other .Net object that
is light weight which will give me the ROW/COLUMN concept.Please also note that we do want to store data in the
COLUMNS with different datatypes. For example I could have2 columns. Column 1 is a string and Column 2 is a double.

Thanks,
.

Nov 15 '05 #2
Thanks for the reply,

But how to I get the number of retrieved when using the
DataReader when applying SELECT queries.

Thanks
-----Original Message-----
Hello,

You could try using a multidimentoial array:

object[,,] oArr = new object[ 20, 4 ];

Then you can stick anything you want in any cell, but be
aware that some boxing and unboxing will occur.

You could create a typed multidementiona l array:

object[] rs = new object[4]; // 4 equals the column count
rs[0] = new int[20]; // 20 equals the row count
rs[1] = new string[20];
rs[2] = new double[20];
rs[3] = new bool[20];

double tmp = ((double[])rs[2])[15]; // 3rd column of 16throw

or if you are reading from a database you could use a
DataReader. ( Its forward only and read only )

Hope this helps.

Jeff
-----Original Message-----
Hello,

We are using DataTable to store our data that we

retrieve
from SQL because it provides us with ROW/COLUMN concept.Due to DataTable been memory hungary we are finding thatat least 40MB of memory is been created every second

which
means the GC is concently running. We want to use
something else that is not memory hungary and will give

us
the ROW/COLUMN concept (ie Multi-dimension Arrays).

My question is that, is there any other .Net object thatis light weight which will give me the ROW/COLUMN

concept.
Please also note that we do want to store data in the
COLUMNS with different datatypes. For example I could

have
2 columns. Column 1 is a string and Column 2 is a double.
Thanks,
.

.

Nov 15 '05 #3
Hello,

I mean number of rows retrieved.
-----Original Message-----
Thanks for the reply,

But how to I get the number of retrieved when using the
DataReader when applying SELECT queries.

Thanks
-----Original Message-----
Hello,

You could try using a multidimentoial array:

object[,,] oArr = new object[ 20, 4 ];

Then you can stick anything you want in any cell, but be
aware that some boxing and unboxing will occur.

You could create a typed multidementiona l array:

object[] rs = new object[4]; // 4 equals the column countrs[0] = new int[20]; // 20 equals the row count
rs[1] = new string[20];
rs[2] = new double[20];
rs[3] = new bool[20];

double tmp = ((double[])rs[2])[15]; // 3rd column of

16th
row

or if you are reading from a database you could use a
DataReader. ( Its forward only and read only )

Hope this helps.

Jeff
-----Original Message-----
Hello,

We are using DataTable to store our data that we

retrieve
from SQL because it provides us with ROW/COLUMNconcept.Due to DataTable been memory hungary we are findingthatat least 40MB of memory is been created every second

which
means the GC is concently running. We want to use
something else that is not memory hungary and will
giveus
the ROW/COLUMN concept (ie Multi-dimension Arrays).

My question is that, is there any other .Net object

thatis light weight which will give me the ROW/COLUMN

concept.
Please also note that we do want to store data in the
COLUMNS with different datatypes. For example I could

have
2 columns. Column 1 is a string and Column 2 is adouble.
Thanks,
.

.

.

Nov 15 '05 #4
Hello Parker,

I cannot use the 'select count(*)' SQL query because the
code has been converted to C#. This means that I would
have to manually change at least 8000 to 10,000 lines of
code.

Thanks,
-----Original Message-----
Hi Buddy,

DataReader uses a forward only and read only cursor.

The RecordCount is unavailable for this type of cursor until all therecords have been read. Both ADO and DAO return -1 for the RecordCount ofthe equivalent cursor.

You can use "select count(*) from ..." to get the record count.
--
Parker Zhang
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
.

Nov 15 '05 #5
Hello,

Then, how about counting the records as you go through the reader?

http://support.microsoft.com/?id=308352

Would you please explain a little more why you cannot use "select count(*)"?

All you have to do is to add a few lines to get the record number. Why do
you have to change at least 8000 to 10,000 lines?

--
Parker Zhang
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 15 '05 #6
Hello Parker,

Let me explain the actual problem. We've had Microsoft
profile our system and found that there is a lot of GC
taking place (approx 40MB second of memory is been created
and destroyed), the reason behind is that we are using
DataTable to store our data that we get from SQL server.
The reason we use DataTable is that it was the best way we
could see of getting the data from SQL by using the
SqlDataAdapter and then using the Fill method. The problem
is that the Fill method will fill into a Dataset and not
into a DataTable (even though under the cover the DataSet
has a DataTable). So we would then have to copy the data
from the DataSet into our DataTable, this would result to
the DataSet object been destroyed each time. In a given
second we could be doing up to 50-100 separate queries.

So we started looking at using the DataReader so we could
then copy the data directly into our DataTable but the
problem is that when the data is retrieved the number of
records retrieved is sent to the user and then we can then
fetch back the data. The user will then decide how many
records to fetch, for example we might return 100 and the
user only wants the first 50 records. This means we need
to send the total number of records before retrieving the
data. We could do this by caching the data in another
DataTable but this would mean we are back to square one
with the GC.

Please also note that the code has been CONVERTED from
another language called AM (4-GL language) and we are
testing the conversion, the SQL queries is also embedded
in the code so to run an extra query like COUNT(*) is
almost impossible because the queries is passed to a
common function which then runs the query, we would have
to parse the SQL query to perform the COUNT(*) which is
not the route we would want to take as we would prefer to
leave the query parsing to the provider engine.
For example the user will pass in the following query
SELECT Client, Name, PostCode From Client WHERE Name
Like 'Smith%'
Your approach is to do this
SELECT COUNT(*) From Client WHERE Name Like 'Smith%'
and then run the actual query
SELECT Client, Name, PostCode From Client WHERE Name
This query is simpler but when you have joins then it gets
tricker which requires us to parse it.
Thanks,

-----Original Message-----
Hello,

Then, how about counting the records as you go through the reader?
http://support.microsoft.com/?id=308352

Would you please explain a little more why you cannot use "select count(*)"?
All you have to do is to add a few lines to get the record number. Why doyou have to change at least 8000 to 10,000 lines?

--
Parker Zhang
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
.

Nov 15 '05 #7
Hi Buddy,
The reason we use DataTable is that it was the best way we
could see of getting the data from SQL by using the
SqlDataAdapt er and then using the Fill method. The problem
is that the Fill method will fill into a Dataset and not
into a DataTable (even though under the cover the DataSet
has a DataTable). So we would then have to copy the data
from the DataSet into our DataTable, this would result to
the DataSet object been destroyed each time. In a given
second we could be doing up to 50-100 separate queries.


The Fill method will also fill into a DataTable:

Overloads Public Function Fill( _
ByVal dataTable As DataTable _
) As Integer

http://msdn.microsoft.com/library/en...datacommondbda
taadapterclassf illtopic2.asp

Please let me know if you have any questions.

--
Parker Zhang
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 15 '05 #8
Hello Parker,

Thank you, I'll give this a try.

Thanks again,
-----Original Message-----
Hi Buddy,
The reason we use DataTable is that it was the best way wecould see of getting the data from SQL by using the
SqlDataAdapte r and then using the Fill method. The problemis that the Fill method will fill into a Dataset and not
into a DataTable (even though under the cover the DataSethas a DataTable). So we would then have to copy the data
from the DataSet into our DataTable, this would result tothe DataSet object been destroyed each time. In a given
second we could be doing up to 50-100 separate queries.
The Fill method will also fill into a DataTable:

Overloads Public Function Fill( _
ByVal dataTable As DataTable _
) As Integer

http://msdn.microsoft.com/library/en-

us/cpref/html/frlrfsystemdata commondbdataadapterclass filltopic2.asp

Please let me know if you have any questions.

--
Parker Zhang
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
.

Nov 15 '05 #9

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

Similar topics

9
4964
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my webserver runs that part of the script (see attached file, snippet.php), though, it doesn't go through. I don't get an error message or anything...it just returns a "1" (whereas it should return a "0") as far as I can tell. I have read the PHP...
0
2879
by: elcc1958 | last post by:
I need to support a VB6 application that will be receiving disconnected ADODB.Recordset from out DotNet solution. Our dotnet solution deals with System.Data.DataTable. I need to populate a disconnected ADODB.Recordset from System.Data.DataTable data. Below is the source code I am implementing to test the process. I do not get any error, that I can see. The problem I have is that at the end, the recordset seems to be empty. Any...
2
1946
by: Shannon | last post by:
I am having a very strange issue with my asp.net application. I have created a datagrid which dynamically gets populated from a person choosing a value from a dropdown list and entering a quantity into a text box (a simple version of a shopping cart). When I run/debug the web page using the localhost in the page URL (http://localhost/mypage.aspx), the datagrid updates properly when a command button is clicked and all is well. However,...
9
4244
by: adi | last post by:
Hi all, Hope there is a quick fix for this: I am inserting data from one table to another on the same DB. The insert is pretty simple as in: insert into datatable(field1, field2, field3) select a1, a2, a3 from temptable...
1
4555
by: Demetri | last post by:
I have a question / concern regarding the new suggested way of creating a data access layer in an n-tier application. Typically, a web application specifically, using the SOA (Service Oriented Architecture) approach. At various sites such as 15 Seconds (http://www.15seconds.com/issue/050721.htm) they advocate using the TableAdapter wizard to generate the data access layer. Describing the TableAdapter wizard, here is a quote from the...
5
6454
by: sutphinwb | last post by:
Hi - This could be a simple question. When I relate two tables in a datasetet, how do I get that relation to show up in a GridView? The only way I've done it, is to create a separate table in the dataset with a join query for the GetData() select method. I use ObjectDataStore to couple the GridView with the table adapter on the dataset. If I point the ODS at the child table, the GridView will bind to the "normal" select and I end up...
2
1224
by: netasp | last post by:
hi all, I need your help with the following scenario: I am using VS 2005 and SQL server DB, my form has 3 textboxes txtTotalAmount, txtAmountEntered, txtAmountBalance. If txtTotalAmount is $20.00 for example then user can enter $2.00 in cash, $2.00 in MasterCard, $16.00 in Cash ,..etc until total amount is reached then balance will show to user. I just don't know whats the best way to approach this? store everything in
1
7848
by: mfunkmann | last post by:
Hi, I recently got an error and I don't know how to fix it: Error 1 'System.Data.DataColumn' does not contain a definition for 'Windows' C:\c#\CsharpPRO\Form1.Designer.cs 304 77 CsharpPRO I am note sure what to do because all propertiers work, except the System.Data.DataColumn.. I didn't write any code by hand and used the visual studio to set the properties..
6
2945
by: insirawali | last post by:
Hi all, I have this problem, i need to know is there a way i cn use the data adapter's update method in this scenario. i have 3 tables as below create table table1{ id1 int identity(1,1) Constraint pk_table1 Primary Key,
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10257
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8931
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7456
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.