By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,727 Members | 757 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,727 IT Pros & Developers. It's quick & easy.

Fastest way to search a dataset.

P: n/a
UJ
I have a dataset that will have say 10000 records in it with the names of
files that are used by the system. I then have a large directory of files
that correspond to that list of files and want to find any files that are in
the directory but not referenced anymore (trying to do cleanup.) I know how
to do all of the stuff but am looking for opinions/suggestions on the
searching of the table. If you have say 10000 records, what's the fastest
way to find a record with a certain value. Here's a code snippet of what I'm
talking about.

GetListOfFilesInUseByDB

GetListOfFilesOnServer

for each File in GetListOfFilesOnServer
if File not in ListOfFilesInUseByDB
deleteFileFromServer
end if
next

I guess what I'm trying to find out the most efficient way to do that 'not
in ListOfFilesInUseByDB'. I know I could filter the datatable. I could also
do a Select on the datatable but since this could have a large number of
records, I wonder if there's a way to put an index on the datatable so it
will search faster....

Any thoughts would be appreciated.

J.
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
UJ,

When you do this kind of operations it depends how many times do you have to
do it with the same datatable (you cannot search datarows in a dataset).

When you want to search more than is in my opinion probably the best
solution the rowcollection.find
http://msdn.microsoft.com/library/de...sfindtopic.asp

With on the second place the
Dataview.find
http://msdn.microsoft.com/library/de...sfindtopic.asp

The first returns a row the second an index inside the dataview.

I hope this helps,

Cor
Nov 21 '05 #2

P: n/a
10.000 is not so much

i would solve this with a Hashtable wich is as far as i know the one with
the highest search performance ( have seen some Balena test code and believe
me it is fast )
it looks to be ideal in your situation as it exposes a ContainsKey method
wich would hold in your situation the file name

if you do not have a value to store just put in a empty string var

happy coding

M. posseth




"UJ" <UJ@nowhere.com> wrote in message
news:eT*************@tk2msftngp13.phx.gbl...
I have a dataset that will have say 10000 records in it with the names of
files that are used by the system. I then have a large directory of files
that correspond to that list of files and want to find any files that are in the directory but not referenced anymore (trying to do cleanup.) I know how to do all of the stuff but am looking for opinions/suggestions on the
searching of the table. If you have say 10000 records, what's the fastest
way to find a record with a certain value. Here's a code snippet of what I'm talking about.

GetListOfFilesInUseByDB

GetListOfFilesOnServer

for each File in GetListOfFilesOnServer
if File not in ListOfFilesInUseByDB
deleteFileFromServer
end if
next

I guess what I'm trying to find out the most efficient way to do that 'not
in ListOfFilesInUseByDB'. I know I could filter the datatable. I could also do a Select on the datatable but since this could have a large number of
records, I wonder if there's a way to put an index on the datatable so it
will search faster....

Any thoughts would be appreciated.

J.

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.