views:

139

answers:

2

Hi folks !

I know my questions will sound silly and probably nobody will have perfect answer but since I am in a complete dead-end with the situation it will make me feel better to post it here.

So...

I have a SQL Server Express database that's 500 Mb. It contains 5 tables and maybe 30 stored procedure. This database is use to store articles and is use for the Developer It web site. Normally the web pages load quickly, let's say 2 ou 3 sec. BUT, sqlserver process uses 100% of the processor for those 2 or 3 sec.

I try to find which stored procedure was the problem and I could not find one. It seems like every read into the table dans contains the articles (there are about 155,000 of them and 20 or so gets added every 15 minutes).

I added few indexes but without luck...

It is because the table is full text indexed ? Should I have order with the primary key instead of date ? I never had any problems with ordering by dates.... Should I use dynamic SQL ? Should I add the primary key into the URL of the articles ? Should I use multiple indexes for separate columns or one big index ?

I you want more details or code bits, just ask for it.

Basically, every little hint is much appreciated.

Thanks.

+2  A: 

If your index is not being used, then it usually indicates one of two problems:

  1. Non-sargable predicate conditions, such as WHERE DATEPART(YY, Column) = <something>. Wrapping columns in a function will impair or eliminate the optimizer's ability to effectively use an index.

  2. Non-covered columns in the output list, which is very likely if you're in the habit of writing SELECT * instead of SELECT specific_columns. If the index doesn't cover your query, then SQL Server needs to perform a RID/key lookup for every row, one by one, which can slow down the query so much that the optimizer just decides to do a table scan instead.

See if one of these might apply to your situation; if you're still confused, I'd recommend updating the question with more information about your schema, the data, and the queries that are slow. 500 MB is very small for a SQL database, so this shouldn't be slow. Also post what's in the execution plan.

Aaronaught
Thanks for your answer... I always use specific columns names in my SQL code.Althought, there are some colunms i can't index since they contains more than 900 bytes. The DB schema is quite simple ... 4 tables... but i always has to do a inner join on 3 of those... I'll post more infos as soon as i have done sql code to test my stored procedure in studio management.
Developer IT
+2  A: 

Use SQL Profiler to capture a lot of typical queries used in your app. Then run the profiler results through index tuning wizard. That will tell you what indexes can be added to optimize.

Then look at the worst performing queries and analyze their execution plans manually.

Sam
I had use SQL profiler but never found the index tuning wizard... I'll check that right now ! Thanks a lot !
Developer IT
SQL Profiler is not installed with SQL Express.. does it works in remote too ?
Developer IT
@DeveloperID, You can purchase a copy of MS SQL Developer Edition for only $50. It will have all the tools included with enterprise. You shouldn't try to develop without the right tools. http://store.microsoft.com/microsoft/SQL-Server-2008-Developer-Edition/product/C5EA00C9
Sam