SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Store Procedure Problem


Store Procedure Problem

Author
Message
polo.csit
polo.csit
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1732 Visits: 691
When i am running first time sp it will take 30 sec and second time it will execute 1 sec.
My problem is yesterday i am running my report using front end application it will executive success fully(store procedure exe time is 1 sec).but today i am insert some records in the table and running the my report using front end application it will display the time out error and my table have 800000 records.Please check the below my store procedure.How solve the my probelm.



USE [XmlTracker]
GO
/****** Object: StoredProcedure [dbo].[GetXMLDataCHanges] Script Date: 10-08-2017 19:02:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER procedure [dbo].[GetXMLDataCHanges]
(
@uid int
)
as
Begin
select Element,convert(varchar(10),[Previous Date],127) as [Previous Date],[Node Name],
[Out],convert(varchar(10),[Current Date],127) as [Current Date],[In]
from xmlchanges
where uid=@uid
end
SteveHaselschwerdt
SteveHaselschwerdt
SSC Veteran
SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)

Group: General Forum Members
Points: 205 Visits: 45
How many records did you insert before running the SP another time? If it was a significant amount, then it will greatly affect index fragmentation. Rebuilding the index for the 'uid' field might help with that. If there isn't an index on the uid, then you'll definitely want that.

What performance tier is your database? If it's Basic, then I believe you're still using shared resources and performance can greatly vary.
polo.csit
polo.csit
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1732 Visits: 691
before running sp we insert 50000 records and table already have index on uid.



Regards
Pols
SteveHaselschwerdt
SteveHaselschwerdt
SSC Veteran
SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)

Group: General Forum Members
Points: 205 Visits: 45
Have you checked the query plan or index fragmentation yet? Those 50000 records might have pushed the fragmentation to the point where it might start running scans instead of seeks.
polo.csit
polo.csit
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1732 Visits: 691
query plan and fragmentation good.



regards
pols
Chris Harshman
Chris Harshman
SSC-Dedicated
SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)

Group: General Forum Members
Points: 34182 Visits: 6685
I'd check statistics first before worrying about index fragmentation.

SELECT SCHEMA_NAME(o.schema_id) AS SchemaName, o.name AS TableName, i.name AS IndexName,
s.name AS StatsName, STATS_DATE(s.object_id, s.stats_id) AS StatsDate,
si.rowmodctr AS RecordsModified, si.rowcnt AS TotalRecords, si.rowmodctr*100.0/si.rowcnt AS pct
FROM sys.objects o
INNER JOIN sys.stats s ON o.object_id = s.object_id
LEFT OUTER JOIN sys.indexes i ON o.object_id = i.object_id
LEFT OUTER JOIN sys.sysindexes si ON i.object_id = si.id AND i.index_id = si.indid
WHERE o.type = 'U'
AND o.name = 'xmlchanges'

polo.csit
polo.csit
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1732 Visits: 691
Please check the attache file for above result data.



Regards
Pols

Attachments
polo.csit
polo.csit
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1732 Visits: 691
my azure database is Basic 2GB only and reaming space 600MB.but still my problem not solve.



regards
pols
Chris Harshman
Chris Harshman
SSC-Dedicated
SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)

Group: General Forum Members
Points: 34182 Visits: 6685
What have you tried to resolve this? The statistics don't look out of date, but you haven't actually given us the table and index definitions, or the execution plan. We'd probably need to see those to help you out much further.
SteveHaselschwerdt
SteveHaselschwerdt
SSC Veteran
SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)

Group: General Forum Members
Points: 205 Visits: 45
If you're using Basic, you could be running into a resource constraint. Have you tried looking at the Azure portal to see whether memory, CPU, or IO are getting pegged?
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search