Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Deadlocks on high traffic forum

Author  Topic 

TurdSpatulaWarrior
Starting Member

36 Posts

Posted - 2004-02-13 : 03:34:53
The forum I'm in charge of has 1 million plus posts and just shy of 100k topics. Recently we've been getting a good deal of deadlocks on the posts and topics tables. The machine it's running on is a quad xeon 550 mhz machine with a meg of cache on each processor, along with 2 gigs of ram. Average daily concurrent forum users is anywhere between 400-500 logged in users, with high spots of up to 700+ logged in users.

Here's the tables:


CREATE TABLE [dbo].[Topics] (
[ID] [int] IDENTITY (1, 1),
[Forum] [int],
[Subject] [varchar] (200),
[Icon] [smallint],
[Replies] [int],
[FirstUserID] [int],
[LastUserID] [int],
[LastPost] [datetime],
[Views] [int],
[Poll] [int],
[Locked] [tinyint] ,
[LockedOn] [smalldatetime]
) ON [PRIMARY]

ALTER TABLE [dbo].[Topics] WITH NOCHECK ADD
CONSTRAINT [PK_Topics] PRIMARY KEY CLUSTERED
(
[ID] DESC
) WITH FILLFACTOR = 55 ON [PRIMARY]

CREATE INDEX [IX_Topics] ON [dbo].[Topics]([LastPost] DESC , [Forum]) WITH FILLFACTOR = 75 ON [PRIMARY]

CREATE INDEX [IX_Topics_1] ON [dbo].[Topics]([FirstUserID] DESC , [LastUserID] DESC ) WITH FILLFACTOR = 55 ON [PRIMARY]


CREATE TABLE [dbo].[Posts] (
[ID] [int] IDENTITY (1, 1),
[SID] [int],
[Topic] [int],
[Subject] [varchar] (200),
[Message] [text],
[UserID] [int],
[Posted] [datetime],
[Image1] [varchar] (5),
[Image2] [varchar] (5),
[Image3] [varchar] (5),
[Image4] [varchar] (5),
[Image5] [varchar] (5),
[IP] [varchar] (15),
[Edited] [datetime],
[EditIP] [varchar] (15),
[Inserted] [timestamp]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]


ALTER TABLE [dbo].[Posts] WITH NOCHECK ADD
CONSTRAINT [PK_Posts] PRIMARY KEY CLUSTERED
(
[ID] DESC
) WITH FILLFACTOR = 95 ON [PRIMARY]

CREATE INDEX [IX_Posts] ON [dbo].[Posts]([Topic] DESC , [SID]) WITH FILLFACTOR = 95 ON [PRIMARY]

CREATE INDEX [IX_Posts_1] ON [dbo].[Posts]([UserID]) WITH FILLFACTOR = 95 ON [PRIMARY]


Of note:
- Posts.Topic is foreign key to Topic.ID
- Posts.SID is Sequential ID field for that topic (numbers the posts of the topic)
- I DBCC DBREINDEX both of these tables once a week during off-peak hours
- for a little extra speed, the database is on simple recovery mode


Are my indexes horribly off or something? I'm just trying to make sure I can squeeze all the performance out of this box as we can before telling the boss it's time to open his wallet for a nice new machine. If I'm spelling horrible or am being retarded about something I apologize; it's 3:30 AM here in NY right now...

Thx,
Jay

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2004-02-13 : 06:09:33
You would be better served if you could post (a sample of) the SQL of the most typical search query(s) to advance the process any more.....there are 2 side to performance problems...a) database structure and b) database access method.....you're only letting us express a viewpoint on the former.


However...some comments to get the ball rolling.
a)....the clustered index on TOPICS...what i've seen seems to suggest that one of it's benefits is to improve range searches....in this case on the ID column....do you utilise this? would it be better to cluster on some other columns...or remove clustering altogether?

b)IX_Topics...would only be useful...if the search query specifies (down to the millisecond) the lastpost time os a particular topics....it might be more useful to reverse the order of the columns in this index...in this community...a lot of searches of topics....start from the forum and list all posts in descending time order....i can't see why the same principle doesn't operate with yourself.

c) PK_Posts....could the clustering be moved to (an)other column(s)....would it not make performance sense that all posts for a topics be contiguous?....because when listing a topic...usually all posts to that topics are returned at the same time.


Sounds like you've got a success story that is in danger of becoming a failure....corrective action now may redirect your boss to spend his $ in a more appropriate direction....like into your back pocket!
Go to Top of Page
   

- Advertisement -