I have a child table (~1.2B rows) that I need grouped (and a COUNT), but I'd like to do it based on a filter that's applied to a parent table. To illustrate;
This is very slow:
SELECT IdValue, COUNT(*) as SuccessCount
GROUP BY IdValue
This is very fast:
WHERE IdValue = @IdValue
The IdValue is the singleton value selected from a drop down filter. Is this possible?
I can start researching fancier in-database solutions, but if there were some way to "defer" the query to TableSuccesses until after a filter was selected, that would make my life much easier.
Retrieving data ...