473,490 Members | 2,737 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Efficient way of querying datasets in c#

Guys,

I have an XML file which is 233MB in size. It was created by loading 6
tables from an sql server database into a dataset object and then
writing out the contents from this dataset into an XML file.

Once my application starts, I load this XML file into a DataSet object
using "ReadXML" function. This creates a dataset in memory with 6
tables.

I then run a query against a table as such: ds.Tables[i].Select("Query
String");

When I run a query against a small table (i.e. < 10,000 rows), I get
results under a second. However, when I run a simple select query
against a large table (~ 2 million records), the query takes almost a
minute. Is there a way to optimize this approach to achieve the same
result?

Basically, I don't want to deal with a database, but rather have XML
files loaded as datasets (i.e. in-memory objects) and run queries
against the datasets.

Is there a more efficient way of doing this?
Thank you very much

Dec 19 '06 #1
5 3672


"sql_er" <sq****@yahoo.comwrote in message
news:11*********************@73g2000cwn.googlegrou ps.com...
Guys,

I have an XML file which is 233MB in size. It was created by loading 6
tables from an sql server database into a dataset object and then
writing out the contents from this dataset into an XML file.

Once my application starts, I load this XML file into a DataSet object
using "ReadXML" function. This creates a dataset in memory with 6
tables.

I then run a query against a table as such: ds.Tables[i].Select("Query
String");

When I run a query against a small table (i.e. < 10,000 rows), I get
results under a second. However, when I run a simple select query
against a large table (~ 2 million records), the query takes almost a
minute. Is there a way to optimize this approach to achieve the same
result?
Yes. Load the data into SQL Server. It's quite good at querying data.
>
Basically, I don't want to deal with a database, but rather have XML
files loaded as datasets (i.e. in-memory objects) and run queries
against the datasets.
You could try SQL Server Compact Edition, which is a light-weight, embedded
database engine if you don't want to install SQL Server Express Edition.
Is there a more efficient way of doing this?
You can navigate large in-memory Data Sets efficiently, but you shouldn't
expect queries to be efficient. If you know the access paths for the data
tables you can build indexes on the data tables, or you could populate
external memory structures, like a Dictionary<string,IList<DataRow>to
provide quick lookups. But you shouldn't depend on fantastic performance
from ADO.NET processing queries against datasets with millions of rows.
That's just not the problem they were designed to solve.
David

Dec 19 '06 #2
"sql_er" <sq****@yahoo.comwrote in message
news:11*********************@73g2000cwn.googlegrou ps.com...
I have an XML file which is 233MB in size.
This is a joke, right...?
When I run a query against a small table (i.e. < 10,000 rows), I get
results under a second.
Consider yourself very fortunate...
However, when I run a simple select query against a large table
(~ 2 million records), the query takes almost a minute.
You're surely not surprised by that...?
Is there a way to optimize this approach to achieve the same result?
There is - use a database. That's what they're for. They have all sorts of
functionality such as indexes and stored procedures which you can never hope
to achieve with XML.

Without any doubt whatsoever, the biggest mistake you can make with XML is
to try to use it as a replacement for a database. That's not what it's for
at all.
Basically, I don't want to deal with a database,
Are you perhaps a masochist...?
Is there a more efficient way of doing this?
See above.
Dec 20 '06 #3
When you state, "Basically I don't want to deal with a database", what is the
rationale behind this statement? Are databases evil? Or do you just have a
setup for your application that makes it difficult to install a database?

If you want really high-performance from an in-memory database, you may want
to take a look at SQLite with the ADO.NET 2.0 provider. It's all in a single
assembly that requires zero installation, and it has an "in-memory" database
option that is lightning fast. You would load your tables at application
startup, create any in-memory indexes you need to speed up queries, and off
you go with regular SQL instead of the limited "pseudo SQL" that DataSets
offer.

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"sql_er" wrote:
Guys,

I have an XML file which is 233MB in size. It was created by loading 6
tables from an sql server database into a dataset object and then
writing out the contents from this dataset into an XML file.

Once my application starts, I load this XML file into a DataSet object
using "ReadXML" function. This creates a dataset in memory with 6
tables.

I then run a query against a table as such: ds.Tables[i].Select("Query
String");

When I run a query against a small table (i.e. < 10,000 rows), I get
results under a second. However, when I run a simple select query
against a large table (~ 2 million records), the query takes almost a
minute. Is there a way to optimize this approach to achieve the same
result?

Basically, I don't want to deal with a database, but rather have XML
files loaded as datasets (i.e. in-memory objects) and run queries
against the datasets.

Is there a more efficient way of doing this?
Thank you very much

Dec 20 '06 #4

"David Browne" <davidbaxterbrowne no potted me**@hotmail.comwrote in
message news:eL**************@TK2MSFTNGP02.phx.gbl...
Yes. Load the data into SQL Server. It's quite good at querying data.
Just to add to what David told you, with SQL 2005 you can also create XML
Indexes on XML columns which can improve query performance significantly.
I've seen XQuery queries drop from 70+ seconds on a very large XML document
to under 2 seconds on the same document by using the XML indexes on SQL 2K5.
Dec 20 '06 #5
If you know the access paths for the data tables you can build indexes on the data tables, or you could populate external memory structures, like a
Dictionary<string,IList<DataRow>to provide quick lookups. But you shouldn't depend
on fantastic performance
Guys,

Just to clarify: I have nothing against databases. I am actually a
database programmer. I know that databases are efficient and were
designed to specifically deal with lots of data. It is just that we
have 5 databases, each a copy of each other, sitting on different
machines. The reason for having 5 identical dbs on different machines
is for load balancing issue.

I was just wondering if it would be possible to replace the dbs with an
xml file, knowing that the queries we run against the are extremely
simple (i.e. simple selects). This approach was purely explorational.

As it turned out from my own experimentation and from what I have heard
from all of you, XML is not the way to go. I guess I'll stick to
databases in that case.

However, since I deal with XML files anyway, but never heard about
indexing (i.e. until now) I would like to know how it can be done.
Could you guys give me more detail about how an XML file can be indexed
and once indexed, do I need to use X-query for indexes to be used OR
could I still load it into a dataset in C# and indexing information
will be loaded with it as well?
Thank you very much

Dec 20 '06 #6

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

Similar topics

21
2397
by: Chris S. | last post by:
I have a number of strings, containing wildcards (e.g. 'abc#e#' where # is anything), which I want to match with a test string (e.g 'abcdef'). What would be the best way for me to store my strings...
6
1390
by: Mike O. | last post by:
What's the most efficient way to store small messages (similar in size to a short email) on the client without using a database? I need to be able to store thousands possibly. I was thinking of...
2
1387
by: Elliot Rodriguez | last post by:
As I continue to read more about the benefits of database querying using ADO.NET, I am having a more difficult time distinguishing what the best approach to data retrieval is anymore. When...
2
2296
by: Jim Kitterman | last post by:
I am looking for the most efficient way of searching a large xml document (> 14mg). If I could get some pointers in the right direction. I am using VB.NET. It is readonly.
0
1100
by: Andrew Mueller | last post by:
Hello, Not sure how to give a quick explaination, but... I have an application which queries a proprietary archive. I do this using OLEDB with datasets and OLEDBDataAdapter. I am making...
5
2569
by: Alan Little | last post by:
I have affiliates submitting batches of anywhere from 10 to several hundred orders. Each order in the batch must include an order ID, originated by the affiliate, which must be unique across all...
21
1972
by: py_genetic | last post by:
Hello, I'm importing large text files of data using csv. I would like to add some more auto sensing abilities. I'm considing sampling the data file and doing some fuzzy logic scoring on the...
5
2726
by: bob | last post by:
Hi, My app needs to read a text file, compare the data to that already stored in the DB and generate a text file of the differences. The UI displays the text file data and the db data in a...
3
2820
by: Ken Fine | last post by:
This is a question that someone familiar with ASP.NET and ADO.NET DataSets and DataTables should be able to answer fairly easily. The basic question is how I can efficiently match data from one...
0
7112
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
6974
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
7146
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
7183
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
7356
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4573
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...
0
3084
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...
1
628
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
277
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.