I have build sql stored procedures with table valued parameters(as filters passed to diq table) to get data from diq table witch have more than 15000000 record and save count of female and male counts grouped by their age cohort in another table (summery table)
create proc SP_fillSmryAgeCohort
(
@psc as tempProcCode readonly,
@refc as tempRefCode readonly,
@relc as tempRelCode readonly,
@ethc as tempEthCode readonly,
@cntc as tempCntryCode readonly,
@fromDate datetime,
@toDate datetime
)
as
begin
SET nocount ON
declare @SQL NVARCHAR(1000)
declare @PscCount int
declare @refcCount int
declare @relcCount int
declare @ethcCount int
declare @cntcCount int
set @PscCount = (select COUNT(psc) from @psc)
set @refcCount = (select COUNT(refc) from @refc)
set @relcCount = (select COUNT(relc) from @relc)
set @ethcCount = (select COUNT(ethc) from @ethc)
set @cntcCount = (select COUNT(cntc) from @cntc)
delete from dbo.FilterSmryAgeCohort
SET @SQL = 'insert into FilterSmryAgeCohort
(cnt,sexcode,AgeCohortText) select count(distinct id)cnt,sexcode,AgeCohortText from diq
WHERE 1=1'
IF(@PscCount > 0)
BEGIN
SET @SQL = @SQL + 'AND diq.psc in (select psc from @psc )'
END
IF(@refcCount > 0)
BEGIN
SET @SQL = @SQL + 'AND diq.refc in (select refc from @refc )'
END
IF(@relcCount > 0)
BEGIN
SET @SQL = @SQL + 'AND diq.relc in (select relc from @relc )'
END
IF(@ethcCount > 0)
BEGIN
SET @SQL = @SQL + 'AND diq.ethc in (select ethc from @ethc )'
END
IF(@cntcCount > 0)
BEGIN
SET @SQL = @SQL + 'AND diq.cntc in (select cntc from @cntc )'
END
SET @SQL = @SQL + 'and diq.regdate>= @fromDate
and diq.regdate<= @toDate group by sexcode,AgeCohortText'
EXECUTE sp_executesql @SQL,
N'@psc tempProcCode READONLY , @refc tempRefCode READONLY , @relc tempRelCode READONLY ,
@ethc tempEthCode READONLY ,@cntc tempCntryCode READONLY ,@fromDate datetime ,@toDate datetime' ,
@psc, @refc , @relc , @ethc , @cntc , @fromDate , @toDate
end
go
and I'm calling it from my MVC web application
using entity framework 6 exrtas package
the first time I call the procedure from my application is done successfully with no errors, but when I call it for more than one time repeatedly that causes Timeout expired exception
"Error: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding"
I need help to get more information about this exception and what is the reasons of it, and how to solve it ??
thx :)