May 22, 2014 at 4:36 am
Hi all folks!
In my production environment, I have this working stored procedure:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[spDistintaDistriNoDef]
-- Add the parameters for the stored procedure here
@bollaData smalldatetime,
@bollaTipo varchar(2),
@confCod smallint,
@listGiri varchar(MAX),
@listClienti varchar(MAX),
@listProd varchar(MAX)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'tmpRiepilogoGiro') AND type in (N'U'))
BEGIN
DROP TABLE dbo.tmpRiepilogoGiro
END
-- Insert statements for procedure here
SELECT
disProdotti.bollaData
, disProdotti.bollaTipo
, disProdotti.cod
, disProdotti.numero
, disProdotti.varProd
, disProdotti.nome
, disProdotti.formPacco1
, disProdotti.prezzoStampato
, 0 AS alfaOrder
, disBolle.quanDist AS copie
, dbo.fxComputePacchiInteri(disBolle.quanDist, disProdotti.formPacco1) AS pacchiInteri
, dbo.fxComputeSciolti(disBolle.quanDist, disProdotti.formPacco1) AS sciolti
, disClienti.cod AS CodCliente
, disClienti.nome AS NomeCliente
, disClienti.indir
, disClienti.local
, disClieGiri.GiroCod
, disClieGiri.GiroPos
INTO
tmpRiepilogoGiro
FROM
disProdotti INNER JOIN
disBolle ON disProdotti.id = disBolle.prodId INNER JOIN
disClienti ON disBolle.clieId = disClienti.id INNER JOIN
disClieGiri ON disClienti.cod = disClieGiri.clieCod
WHERE
(disClieGiri.confCod = @confCod) AND
(disProdotti.bollaData = @bollaData) AND
(disProdotti.bollaTipo = @bollaTipo) AND
(disProdotti.cod IN (SELECT cod FROM dbo.SplitCustomers(@listProd))) AND
(disClieGiri.GiroCod IN (SELECT cod FROM dbo.SplitCustomers(@listGiri))) AND
(disClienti.cod IN (SELECT cod FROM dbo.SplitCustomers(@listClienti)))
ORDER BY
disClieGiri.GiroCod
, disClieGiri.GiroPos
, disProdotti.nome
END
I have a VB6 application that set the parameters and execute the stored procedure; after this task the same application invoke an external .NET report viewer application that render the report.
Now the problem: my customer starts with 2 workstation for printing (some years ago) and now this workstations are 5.
Every operator produce a new report every 3 minutes.
Performance are poor and sometimes, one operator see the result of another operator.
How could I address this problem?
Any suggestion would be greatly appreciated, thanks.
May 22, 2014 at 5:53 am
1. What does the execution plan look like? Do you see scans instead of seeks? Does the plan suggest indices? These could be performance factors.
2. the Order by clause is meaningless in a SELECT...INTO. You can remove it.
3. What should stop one operator from seeing another's results? It's not clear from the query.
May 22, 2014 at 5:58 am
by simply changing to using a true temp table, isntead of a permenant table which happens to start with tmp, you could fix your concurrency issue.
#temp tables are unique to the session calling it,a nd are destroyed at the end of your procedure,s o there's no need to explicitly check for and drop.
it looks to me like the procedure "refreshes" the data in your table...all it does is drop teh table, recreate it, with data
why not leave the table as is, and simply delete and insert instead?
then you would not have a schema lock on the table for the drop and recreate.
Lowell
May 22, 2014 at 6:32 am
Lowell, thanks for your suggestions, I'm going to apply them to my test environment and I'll report later if these fixes will solve my concurrency problem.
Thanks for your suggestions.
Let me clarify that performance issue is not related to the stored procedure itself (that runs well); is the .NET report application that runs slowly when multiple users try to produce different report almost simultaneously.
Birby
June 24, 2014 at 6:57 am
Hi all, I apologize for the delay of my feedback.
I used the solution suggested by Lowell, and I did some changes to my client (VB6 and C#) applications.
So, I solved my problem.
Thanks!
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply