I have a method that I write where I want to be able to filter orders based on whether they have one or more ordered products that exist when choosing products made by the user. I am currently doing this with:
SelectedProductIDs.Intersect(orderProductIDs).Any()
runs on every order (~ 20,000 orders in the database and is expected to grow rapidly), where both SelectedProducts and orderProductID are strings []. I also tried using pre-generated HashSets for both SelectedProductID and orderProductID, but this did not show a noticeable difference in the speed of comparison.
However, both of them are unpleasantly slow - ~ 300 ms to change the choice, especially considering that the dates provided to the sliders in the user interface are completely based on the results of this request, so user interaction should stop somehow, Is there (very) a significantly faster way to do this?
Edit: it may not have been clear enough - order objects are implemented from SQL data at startup, and these queries are executed later in the secondary window of the general application. SQL is not specific to this issue; This is a LINQ-to-Objects question.
source
share