Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Alternate of materialized/Indexed views to avoid excessive table reads where Min/Max is required for future dates calculations

$
0
0
Hi,

I have a similar situation as in the following code where i want to materialize future due orders to avoid excessive reads in the procedure which at the moment i am handling using co-related sub-queries or even APPLY. 

USE[AdventureWorks2012]-- SQL 2012 Std EditionGO--CREATE VIEW Sales.future_order_Due_Date--WITH SCHEMABINDING--ASSELECT[CustomerID],[SalesPersonID],MIN([OrderDate])AS OrderDate,MIN([DueDate])AS DueDate,MIN([ShipDate])AS ShipDateFROM[Sales].[SalesOrderHeader]GROUPBY[CustomerID],[SalesPersonID]HAVINGMIN([DueDate])>'2007Jan01'--getdate()

So what is the alternate option available to avoid excessive reads from table in every query and in many SPs wherever i need to use this logic?

Thanks.

For quick review of new features, try virtual labs: http://msdn.microsoft.com/en-us/aa570323


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>