Closed SreemonPremkumarMuthukrishnan closed 2 weeks ago
Tagging subscribers to this area: @roji, @ajcvickers See info in area-owners.md if you want to be subscribed.
Hi, Is there any way to improve or optimize the performance of filtering in a DataTable? Specifically, I am looking for methods or best practices that can enhance efficiency and reduce the processing time for large datasets.
@SreemonPremkumarMuthukrishnan you are setting the DataTable's RowFilter to a filter that is 308k big; this is very much not the way that DataTable was meant to be used, and it's indeed expected for this to be very slow. Note that no real database will perform well with such a huge SQL query (and most will probably refuse to run it altogether).
In general, DataTable is an in-memory storage layer that isn't meant for use with huge datasets, and will certainly not work very efficiently (regardless of your specific huge RowFilter). I'd suggest using a real relational database which can properly handle such scenarios. For simplicity and for getting started, you may want to consider SQLite.
Description
Description
When filtering the DataTable using the DefaultView.RowFilter property, it takes a long time (more than 2 minutes) to apply the filter. The number of items being filtered is 5,800. Please find the code snippet below.
Is there any way to improving the performance of filtering.
Note: The filter string was provided along with the sample.
C# code:
Output reference:
https://github.com/user-attachments/assets/d4e746c9-d665-4c53-b3c0-76f6167296f9
Sample:
DataTable_Filtering_Demo.zip
Reproduction Steps
Expected behavior
The filter should not take too much time.
Actual behavior
The filtering takes too much time.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response