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
 General SQL Server Forums
 New to SQL Server Administration
 Advice sought on growing database, CMS & business!

Author  Topic 

Groaning
Starting Member

4 Posts

Posted - 2010-05-13 : 11:51:14
Hello

We're a small company with a growing number of clients using our content management system and sharing a MS SQL database. The CMS and websites are in classic ASP and hosted on a shared server at a large hosting company who controls access to it tightly.

None of us are trained DBAs and we've picked up what we know organically as the company has grown. We have about 50 websites using the CMS and database, none of them very high traffic.

Increasingly we have a problem where the database seems to grind to a halt, and our websites give us script timeout errors. (There's no problem with pages that don't access the database.)

The hosts tells us this is either the fault of queries that need optimising, or because too many website are sharing the same database and we should separate some of them (but this seems counter-intuitive to our CMS model).

We can't seem to (or don't know how to) do any kind of monitoring on the remote database since we don't have access to the server, only to the database, and even then some functionality in say SQL Server Management Studio seems to be unavailable.

We'd be really grateful if anyone has advice on the following questions:

(a) How might we isolate where this problem is coming from?
(b) Are we running "too many websites on the same database"?
(c) What's a good method of deciding if a query needs optimising?
(d) Is this an unsustainable model for our business?
(e) Is there a way we can get our websites working at the click of a button?!

Many thanks for any advice you might have.

Groaning

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-05-13 : 12:03:36
There is an awful lot of ground to cover for perf tuning. it's hard to judge how much you know about indexing and query optimisation so my advise is that you should start here:
http://support.microsoft.com/kb/298475
and then especially:
http://www.sqlteam.com/article/sql-server-indexes-the-basics

Once you've read those you should have a good idea of the tools and things to look for.

Then, hopefully, you'll be able to isolate some problem targets and we can help further.
Good luck.


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-05-13 : 12:04:27
a) Difficult if the Host ties it down tightly. You could have your APP record the start/end time of page rendering and log that, and see what patterns / volume you are getting

b) Nah. We aren't taking 10's-of-millions of rows in your biggest table presumably?

c) Well ... apart from (a) you could use SQL Profiler to log long-running queries, that will tell you the worst offenders (although a faster query, but running much more often, might be in more urgent need of optimising)

d) Nope. You just need a good DBA to sort it out (if you are near me I'm for hire )

e) No. But nice try!

One thing might be that your database has no routine maintenance - Index Rebuilds and Update Statistics. If that's the case that's almost certainly the problem - over time the queries will be using inefficient query plans, and the indexes will be shot full of holes, extension pages tagged-on-to-other-extension pages - you get the idea I expect

Other possibility is that your host is jamming more and more clients onto the share machine - might be worth looking at a dedicated machine; you would have more responsibility for management of the server (so some risk that you are not experienced enough and might have an avoidable accident as a result), but you'd be able to do whatever you liked with the box, and not be at the mercy of other shared-hosting performance hogs

What version of SQL are you on? (Newer versions allow you to do some of the SQL Profiler stuff just y using database queries)

Can you get a backup of your database to try locally? You might be able to simulate some of the issues locally - i.e. without high concurrent load, and thus discover what the slow queries are.
Go to Top of Page

Groaning
Starting Member

4 Posts

Posted - 2010-05-13 : 13:13:39
Thank you both very much indeed! We'll take a good look.

Kristen, if you're anywhere near London we might take you up on the offer... Sounds like getting someone in to clean up the immediate problems and buy us some time would be ideal.

G
Go to Top of Page

Groaning
Starting Member

4 Posts

Posted - 2010-05-13 : 13:15:13
P.S. It's SQL Server 2008 - any tips for useful queries would be gratefully received!
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-05-13 : 13:36:47
quote:
Originally posted by Groaning

if you're anywhere near London we might take you up on the offer...



Suffolk you'll have to brace yourself for my fee rate though!

SQL2008 may help, you may well be able to get some queries of performance without needing to get a connection for SQL Profiler (which your hosting company may block)

Anyway, first up look at whether index rebuild is being done. You can kick that off manually (but do it when your users are "quiet" as it may be very intrusive for people trying to use the system)

Might be worth trying this script to see if there is fragmentation in the indexes:

SELECT [Database] = db.name,
[Object ID] = ps.OBJECT_ID,
[Name] = OBJECT_NAME(ps.OBJECT_ID),
[Index ID] = ps.index_id,
[Partition No.] = ps.partition_number,
[Fragmentation = ps.avg_fragmentation_in_percent,
[Page count] = ps.page_count
FROM sys.databases AS db
INNER JOIN sys.dm_db_index_physical_stats (NULL, NULL, NULL , NULL, N'Limited') AS ps
ON db.database_id = ps.database_id
WHERE ps.index_id > 0
AND ps.page_count > 100
AND ps.avg_fragmentation_in_percent > 30
AND db.name = 'MyDatabaseName'
OPTION (MaxDop 1)


this will generate you a script to rebuild your indexes and update statistics

SET NOCOUNT ON
SELECT 'PRINT ''Reindex ' + [name] + ''''
+ CHAR(13)+CHAR(10) + 'GO'
+ CHAR(13)+CHAR(10) + 'ALTER INDEX ALL ON dbo.[' + [name] + '] REBUILD '
+ 'WITH (ONLINE=OFF, STATISTICS_NORECOMPUTE = OFF)'
+ CHAR(13)+CHAR(10) + 'GO'
FROM sys.tables
ORDER BY [name]
--
SELECT 'PRINT ''Update Stats ' + [name] + ''''
+ CHAR(13)+CHAR(10) + 'GO'
+ CHAR(13)+CHAR(10) + 'UPDATE STATISTICS dbo.[' + [name] + '] WITH FULLSCAN'
+ CHAR(13)+CHAR(10) + 'GO'
FROM sys.tables
ORDER BY [name]
--
SET NOCOUNT OFF
Go to Top of Page

Groaning
Starting Member

4 Posts

Posted - 2010-05-14 : 11:42:35
Thanks again Kristen! The first of those wouldn't run as we "don't have the privileges" etc - something we're up against - but I'm going to read up and try the second and see how far I can get before squeaking again. Thank you!
Go to Top of Page
   

- Advertisement -