Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How does DataView.RowFilter works?

How does DataView.RowFilter works?

Scheduled Pinned Locked Moved Database
comquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alexandru Savescu
    wrote on last edited by
    #1

    Hi, I have a DataTable that has a primary key. If I want to find a row by primary key I can use DataTable.Rows.Find (new object [] {id}), or I can perform a row filter like Mytable.DefaultView.RowFilter = "ID = " + id. It looks like RowFilter is MUCH slower than Find. Any idea why? Does RowFilter perform a linear search and Find does some binary search? Thanks Best regards, Alexandru Savescu P.S. Interested in art? Visit this!

    H 1 Reply Last reply
    0
    • A Alexandru Savescu

      Hi, I have a DataTable that has a primary key. If I want to find a row by primary key I can use DataTable.Rows.Find (new object [] {id}), or I can perform a row filter like Mytable.DefaultView.RowFilter = "ID = " + id. It looks like RowFilter is MUCH slower than Find. Any idea why? Does RowFilter perform a linear search and Find does some binary search? Thanks Best regards, Alexandru Savescu P.S. Interested in art? Visit this!

      H Offline
      H Offline
      Husein
      wrote on last edited by
      #2

      I have discovered the same thing. In a test application that I created the results were REALLY unbelievable. The thing that I did was: 1. Connect to SQL Server 2. Use Northwind as Initial Catalog 3. Filled the dataset with Customers table records After using DataTable.Rows.Find("MORGK"), the time taken was 40 milliseconds After using DataTable.DefaultView.Find("MORGK"), the time taken was 0(?) :wtf: milliseconds but the record index was correctly found and the return value was 51. After using DataView.RowFilter the time taken was 70 milliseconds. And then, going through the documentation, DataTable.Rows.Find() uses PrimaryKey to locate the record. There was nothing like this for RowFilter so my assumption is that DataView uses an approach like Table Scan which means that PrimaryKey is completely ignored. Also, DataView constantly monitors for new rows and if it matches the criteria it is automatically available in the DataView. I guess this could be a sort of explanation. Husein

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups