question

Raj More avatar image
Raj More asked

Table Inserts timing out

We have a transacations log table dbo.LOG that has 8M rows in it. We add about 25k rows to the table on a daily basis.

Edit

Ther are no triggers on this table.

Indices:

/* LogId is INT */
ALTER TABLE [dbo].[Log] ADD CONSTRAINT [Log_PK] PRIMARY KEY NONCLUSTERED
(
    [LogID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, 
SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, 
ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO

/* ClientPostingDateTime is datetime */
CREATE NONCLUSTERED INDEX [IX_Log_ClientPostingDateTime] ON [dbo].[Log]
(
    [ClientPostingDateTime] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, 
SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, 
DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, 
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO

/* TransactionTypeCode is INT */
CREATE NONCLUSTERED INDEX [IX_Log_TransactionTypeCode] ON [dbo].[Log]
(
    [TransactionTypeCode] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, 
SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, 
DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, 
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO

The insert/updates are coming from a ASP.NET web site on a different server. Both the web server and the SQL server are in the same physical location (possibly on the same rack).

The web site call to the database is timing out. Upto 25 edits (INSERTS / UPDATES) are timing out on this every day.

How do I go about identifying and fixing this issue?

t-sqlperformance
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Grant Fritchey avatar image
Grant Fritchey answered

I would collect the wait states and queues performance monitor counters to see specifically where the slow downs are occurring. Also, if you can see when the timeouts are occurring, it's possible to get the execution plans for the queries being executed straight out of the cache using DMV's. That way you can see if there's something up with the execution plans for these queries different than the ones that succeed.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Kev Riley avatar image
Kev Riley answered

Can you give some more info.

Are there any indexes on the table? If so what fields (with data types).

Are there any triggers?

Where are the insert/updates coming from? App on same physical server, another server? What is the connection between the db server and app server?

What is timing out? The query or the call to the database?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Gustavo avatar image
Gustavo answered

What isolation level/ table hint are you using ? Read Commited is the default, but read uncommited or using the hint with (nolock) lets you read uncommited 'dirty' data from the destination table ignoring simple locks. ( if locks are your problem, try this).

Does your queries are transactioned ? A safe block of operations within a transaction will place locks on everything you touch, so maybe you dont need this rigid control over a log table.

Check system blocks/ locks and wait types to see if several queries are waiting for any shared resource. Some resource could be locking the table for a long time and causing timeouts.

Maybe you are experiencing IO/CPU/MEMORY/NETWORK bottlenecks ( but usually those problems would afect the whole system.

While updating avoid using any hint like with (tablock).

Check for any pattern of those lost logs, maybe they happen exactly when your full backup operation is running.

Let us know if this help.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.