I have a 5 year data set partitioned into quarterly tables. I also have a master view that joins them all together. When a user needs more than one quarter of data they often use the master view instead of joining multiple quarters together.
My question is, would a table valued function which accepts a date range and returns only the records from the necessary partitions be faster than querying the entire master view?
This is my current view definition:
ALTER VIEW [dbo].[loandetails_test]
AS
SELECT *
FROM loandetails05
where year(date) = 2005
UNION
SELECT *
FROM loandetails06
where year(date) = 2006
UNION
SELECT *
FROM loandetails07
where year(date) = 2007
UNION
SELECT *
FROM loandetails08
where year(date) = 2008
UNION
SELECT *
FROM loandetails1q09
where date >= '1/1/2009' and date < '4/1/2009'
UNION
SELECT *
FROM loandetails2q09
where date >= '4/1/2009' and date < '7/1/2009'
UNION
SELECT *
FROM loandetails3q09
where date >= '7/1/2009' and date < '10/1/2009'
UNION
SELECT *
FROM loandetails4q09
where date >= '10/1/2009' and date < '1/1/2010'
UNION
SELECT *
FROM loandetails1q10
where date >= '1/1/2010' and date < '4/1/2010'
UNION
SELECT *
FROM loandetails2q10
where date >= '4/1/2010' and date < '7/1/2010'
UNION
SELECT *
FROM loandetails3q10
where date >= '7/1/2010' and date < '10/1/2010'
UNION
SELECT *
FROM loandetails4q10
where date >= '10/1/2010' and date < '1/1/2011'
union
SELECT *
FROM loandetails_CURRENT
where date >= '1/1/2011' and date < '4/1/2011'
GO
