Performance of DataRowCollection.Find() ?

  • Thread starter Thread starter AAA
  • Start date Start date
A

AAA

Hello,

I'm considering keeping in memory a not-that-big DataTable, with a "classic"
single-column-primary-key, which is 'Stringish'.

Obviously, I will lookup rows based on this key.

My question is simple: is that an indexed operation ? Same as using a
Hashtable ?
Is it O(1), or O(n) ? worst ? better ?

I was trying to use ILDASM, but it just show a call to FindByPrimaryKey :
IL_0007: callvirt instance class System.Data.DataRow
System.Data.DataTable::FindByPrimaryKey(object)

Can anyone help here, pls ?

Thanks

Meir
 
The datatable implements Ilist using the IlistSource,

http://msdn.microsoft.com/en-us/library/system.componentmodel.ilistsource.aspx

Be aware that beside the DataRowCollection.Find their are more possibilities
like the dynmic acting dataview, rowfilter, the dataview.Find,
dataview.findrows and even more.

http://msdn.microsoft.com/en-us/library/system.data.dataview.findrows(VS.71).aspxCor"AAA" <[email protected]> wrote in messageHello,>> I'm considering keeping in memory a not-that-big DataTable, with a"classic" single-column-primary-key, which is 'Stringish'.>> Obviously, I will lookup rows based on this key.>> My question is simple: is that an indexed operation ? Same as using aHashtable ?> Is it O(1), or O(n) ? worst ? better ?>> I was trying to use ILDASM, but it just show a call to FindByPrimaryKey :> IL_0007: callvirt instance class System.Data.DataRowSystem.Data.DataTable::FindByPrimaryKey(object)>> Can anyone help here, pls ?>> Thanks>> Meir>>>>>>>>>
 
Hello Cor,

Thanks for your reply, but I still don't get it:
What is the complexity of DataRowCollection.Find() ?
Is it O(1) ?

I'm just looking for a yes/no answer here, which will determine my
implementation.
Obviously, O(n) or higher is out-of-the-question...

If it is O(1), like for an hashtable, it will do.

If you are trying to say that it is fast and behaves currently with O(1),
and still I can use something better/faster,
than it is of interest to me, of-course. And I will then look into those
other methods you mentioned.

But I first need to understand: is the current behavior reasonable enough
for me to use this ?


I should also specify this: I'm loading the DataSet from an XML, using an
XML schema
that specifies the Primary-Key .
Meaning, no DB involved.
DataSet is very simple: single table, primary key, no relation.


Tx
Meir
 
Back
Top