Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Concurrency read by .net report application Expand / Collapse
Author
Message
Posted Thursday, May 22, 2014 4:36 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, June 24, 2014 6:51 AM
Points: 8, Visits: 89
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.



Post #1573498
Posted Thursday, May 22, 2014 5:53 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, September 11, 2014 6:27 AM
Points: 333, Visits: 742
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.
Post #1573526
Posted Thursday, May 22, 2014 5:58 AM This worked for the OP Answer marked as solution


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 2:34 PM
Points: 12,916, Visits: 32,077
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

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1573529
Posted Thursday, May 22, 2014 6:32 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, June 24, 2014 6:51 AM
Points: 8, Visits: 89
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.

@gbritton:
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
Post #1573545
Posted Tuesday, June 24, 2014 6:57 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, June 24, 2014 6:51 AM
Points: 8, Visits: 89
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!
Post #1585494
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse