简体   繁体   English

SQL Server Express性能问题

[英]SQL Server Express performance issue

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. 我有一个500 Mb的SQL Server Express数据库。 It contains 5 tables and maybe 30 stored procedure. 它包含5个表,可能还有30个存储过程。 This database is use to store articles and is use for the Developer It web site. 该数据库用于存储文章,并用于Developer It网站。 Normally the web pages load quickly, let's say 2 ou 3 sec. 通常,网页加载速度很快,例如2 ou 3秒。 BUT, sqlserver process uses 100% of the processor for those 2 or 3 sec. 但是,sqlserver进程在这2或3秒钟内使用了100%的处理器。

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). 似乎每一次读到表中dans都包含文章(大约有155,000,每15分钟添加20个左右)。

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 ? 我按日期排序从来没有任何问题。...应该使用动态SQL吗? Should I add the primary key into the URL of the articles ? 是否应将主键添加到文章的URL中? 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. 谢谢。

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> . 不可保留的谓词条件,例如WHERE DATEPART(YY, Column) = <something> DATEPART 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 . 输出列表中未覆盖的列,如果您习惯于编写SELECT *而不是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. 如果索引不覆盖您的查询,则SQL Server需要对每一行逐一执行RID /键查找,这可能会大大降低查询速度,以至于优化器只是决定执行表扫描。

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. 对于SQL数据库,500 MB很小,因此这应该不会很慢。 Also post what's in the execution plan. 还要发布执行计划中的内容。

Use SQL Profiler to capture a lot of typical queries used in your app. 使用SQL事件探查器捕获应用程序中使用的许多典型查询。 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. 然后查看性能最差的查询,并手动分析其执行计划。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM