August 10, 2017 at 7:46 am
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
August 10, 2017 at 8:18 am
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.
August 10, 2017 at 8:57 am
before running sp we insert 50000 records and table already have index on uid.
Regards
Pols
August 10, 2017 at 9:10 am
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.
August 10, 2017 at 9:36 am
query plan and fragmentation good.
regards
pols
August 10, 2017 at 9:56 am
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'
August 10, 2017 at 10:21 am
Please check the attache file for above result data.
Regards
Pols
August 11, 2017 at 9:52 am
my azure database is Basic 2GB only and reaming space 600MB.but still my problem not solve.
regards
pols
August 11, 2017 at 10:24 am
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.
August 11, 2017 at 10:40 am
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?
August 22, 2017 at 5:32 am
How many records would you expect to be returned by this: where uid=@uid
Is it one (or a few) or large numbers? The query itself as posted is very simple. Assuming a clustered index on the uid column and a small data set, you should be seeing a seek running fairly quickly. If it's a nonclustered index on uid, then you'd still see a seek if it's only a few rows combined with a key lookup or rid lookup. However, if there is no index on uid or it's returning a bunch of rows, then you're going to see a scan. If it's a bunch of rows, there may not be much that can be done to help. If it's just a missing or incorrect index, that can be fixed.
Also, it could just be network latency if you're testing the retrieval from Azure from your client and your client is not also running in Azure (by the way, that counts as data egress and will cost money).
We're working off of a very limited set of data here (the query). Getting the table structure, including indexes, keys, constraints, and an execution plan (preferably the "actual" plan), would make a big difference. Assuming you're on SQL Server 2016 SP1 or greater, the actual plan of the execution plan will have the run time query performance included in the plan, so you won't have to capture the query metrics separately.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply