Is it possible in Sql Server 2016 to create some indexed View (or equiv) that summarizes a simple Parent / Child relationship.
e.g.:
Parent: Vehicles
Children: Parts (the parts that make up the car)
Children: Workers (the people who helped build the car)
And results like this.. e.g.:
Car | Parts | Workers
Car_A | 1111 | 4
Car_B | 123412 | 54
Car_C | 0 | 0
I guess if I was to write this as a SQL query (which I'm assuming is not indexed then and has to 'calculate' the entire answer):
SELECT a.CarId
FROM Cars a
LEFT OUTER JOIN Parts b ON a.CarId = b.CarId
LEFT OUTER JOIN Workers c ON a.CarId = b.CarId
Now the reason I'm after an 'INDEXED' view is that I'm assuming that the calculations are stored on disk so I only have to do a scan of the index to get ther results, instead of having to calculate the results, on exection.
The example above is also contrite (for this question). In reality i have a larger table structure, etc. etc.
I do understand that Indexed Views can't have specific keywords, like COUNT
(as mentioned by @brentozar in a blog post)
Am I looking at this problem the wrong way? I don't really want to reply on SQL caching and be a bit more proactive, here.
(Note: Maybe I've been doing many Map/Reduce queries in another NoSql db :) )