RowFilter and Find of a DataView

  • Thread starter Thread starter marlon
  • Start date Start date
M

marlon

In a dataview, will setting the RowFilter property increase performance for
the search when using Find Method ?
 
Looks like DataView will find a row only when the row match RowFilter
condition.
So, if you set RowFilter once, subsequent calls to Find method may be
faster.
 
Hello Marlon,

Thanks for posting in the group.

When querying a DataSet for rows that match particular criteria, you can
increase the performance of your searches by taking advantage of
index-based lookups. When you assign a PrimaryKey value to a DataTable, an
index is created. When you create a DataView for a DataTable, an index is
also created. Here are a few tips for taking advantage of index-based
lookups.

*If the query is against the columns that make up the PrimaryKey of the
DataTable, use DataTable.Rows.Find instead of DataTable.Select.

*For queries involving non-primary key columns, you can improve performance
for multiple queries of the data using a DataView. When you apply a sort
order to a DataView, an index is built that is used when searching. The
DataView exposes the Find and FindRows methods to query the data in the
underlying DataTable.

*If you do not require a sorted view of a table, you can still take
advantage of index-based lookups by creating a DataView for the DataTable.
Note that this is only an advantage if you are performing multiple queries
on the data. If you are only performing a single query, the processing
required to create the index reduces the performance gained by using the
index.

DataView Construction

The DataView builds an index for the data in the underlying DataTable when
both the DataView is created, and when the Sort, RowFilter or
RowStateFilter properties are modified. When creating a DataView object,
use the DataView constructor that takes the Sort, RowFilter, and
RowStateFilter values as constructor arguments (along with the underlying
DataTable). The result is the index is built once. Creating an "empty"
DataView and setting the Sort, RowFilter or RowStateFilter properties
afterward results in the index being built at least twice.

So the key point here is the index in searching. The DavaView builds an
index. What we need to do is to reduce its chance to rebuild index. Once
the index is built, RowFilter won't afftect the perfomrance much.

Does that answer your question?
Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "marlon" <[email protected]>
!Subject: RowFilter and Find of a DataView
!Date: Wed, 24 Sep 2003 15:28:00 -0400
!Lines: 4
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
!Message-ID: <[email protected]>
!Newsgroups:
microsoft.public.dotnet.framework.adonet,microsoft.public.dotnet.framework
!NNTP-Posting-Host: 209.131.15.66
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework:54633
microsoft.public.dotnet.framework.adonet:62043
!X-Tomcat-NG: microsoft.public.dotnet.framework
!
!In a dataview, will setting the RowFilter property increase performance for
!the search when using Find Method ?
!
!
!
 
I read .NET documentation that says, that the index is rebuilt if your call
the RowFitler property.
What if an index exists on the dataview and the RowFilter property uses the
same expression (fields),
used to build a previous index. Is the index rebuilt again or does the
dataview checks and re-use the existing index?
 
Hello Marlon,

Thanks for the response.

Based on MSDN, because the index for a DataView is built both when the
DataView is created, and when any of the Sort, RowFilter, or RowStateFilter
properties are modified, you will achieve best performance by supplying any
initial sort order or filtering criteria as constructor arguments when you
create the DataView.

So if the property is not modified, the index won't be rebuilt.

Does that answer your question?

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "marlon" <[email protected]>
!References: <[email protected]>
<[email protected]>
!Subject: Re: RowFilter and Find of a DataView
!Date: Thu, 25 Sep 2003 08:18:04 -0400
!Lines: 88
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
!Message-ID: <#[email protected]>
!Newsgroups: microsoft.public.dotnet.framework
!NNTP-Posting-Host: 209.131.15.66
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework:54709
!X-Tomcat-NG: microsoft.public.dotnet.framework
!
!I read .NET documentation that says, that the index is rebuilt if your call
!the RowFitler property.
!What if an index exists on the dataview and the RowFilter property uses
the
!same expression (fields),
!used to build a previous index. Is the index rebuilt again or does the
!dataview checks and re-use the existing index?
!
!!> Hello Marlon,
!>
!> Thanks for posting in the group.
!>
!> When querying a DataSet for rows that match particular criteria, you can
!> increase the performance of your searches by taking advantage of
!> index-based lookups. When you assign a PrimaryKey value to a DataTable,
an
!> index is created. When you create a DataView for a DataTable, an index is
!> also created. Here are a few tips for taking advantage of index-based
!> lookups.
!>
!> *If the query is against the columns that make up the PrimaryKey of the
!> DataTable, use DataTable.Rows.Find instead of DataTable.Select.
!>
!> *For queries involving non-primary key columns, you can improve
!performance
!> for multiple queries of the data using a DataView. When you apply a sort
!> order to a DataView, an index is built that is used when searching. The
!> DataView exposes the Find and FindRows methods to query the data in the
!> underlying DataTable.
!>
!> *If you do not require a sorted view of a table, you can still take
!> advantage of index-based lookups by creating a DataView for the
DataTable.
!> Note that this is only an advantage if you are performing multiple
queries
!> on the data. If you are only performing a single query, the processing
!> required to create the index reduces the performance gained by using the
!> index.
!>
!> DataView Construction
!>
!> The DataView builds an index for the data in the underlying DataTable
when
!> both the DataView is created, and when the Sort, RowFilter or
!> RowStateFilter properties are modified. When creating a DataView object,
!> use the DataView constructor that takes the Sort, RowFilter, and
!> RowStateFilter values as constructor arguments (along with the underlying
!> DataTable). The result is the index is built once. Creating an "empty"
!> DataView and setting the Sort, RowFilter or RowStateFilter properties
!> afterward results in the index being built at least twice.
!>
!> So the key point here is the index in searching. The DavaView builds an
!> index. What we need to do is to reduce its chance to rebuild index. Once
!> the index is built, RowFilter won't afftect the perfomrance much.
!>
!> Does that answer your question?
!> Best regards,
!> Yanhong Huang
!> Microsoft Online Partner Support
!>
!> Get Secure! - www.microsoft.com/security
!> This posting is provided "AS IS" with no warranties, and confers no
!rights.
!>
!> --------------------
!> !From: "marlon" <[email protected]>
!> !Subject: RowFilter and Find of a DataView
!> !Date: Wed, 24 Sep 2003 15:28:00 -0400
!> !Lines: 4
!> !X-Priority: 3
!> !X-MSMail-Priority: Normal
!> !X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
!> !X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
!> !Message-ID: <[email protected]>
!> !Newsgroups:
!>
microsoft.public.dotnet.framework.adonet,microsoft.public.dotnet.framework
!> !NNTP-Posting-Host: 209.131.15.66
!> !Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
!> !Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework:54633
!> microsoft.public.dotnet.framework.adonet:62043
!> !X-Tomcat-NG: microsoft.public.dotnet.framework
!> !
!> !In a dataview, will setting the RowFilter property increase performance
!for
!> !the search when using Find Method ?
!> !
!> !
!> !
!>
!
!
!
 
Back
Top