如何在存储过程中创建索引 [英] how to create index in the stored procedures

查看:259
本文介绍了如何在存储过程中创建索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





i需要知道如何在存储过程中创建索引。

因为我需要减少执行sp的时间。我的sp有9000条记录

但是当多个用户登录时需要30分钟。所以我怎样才能减少

sp.i google的时间但是没有找到任何解决方案

Hi,

i need know how to create index in the stored procedures.
because i need to reduces time in sp to executes. my sp have 9000 records
but it will take 30 min when multiple user login.so how can i reduces time for
sp.i google it but no find any solution

推荐答案

如果你的意思是临时索引,谷歌可以提供帮助:create index in存储过程 [ ^ ]

但是......如果你要定期索引值,你应该将它们添加到你的数据库表中,而不是在你的SP中动态创建它们。

如果你认为创建它们即时将是解决方案,它非常可能你需要仔细检查你的SP正在做什么,以及它是如何做到的 - 它更可能是一个主要的设计缺陷,这解释了为什么它需要这么长时间才能运行。首先看一下执行计划。这可能有所帮助: http://www.sqlshack.com/sql-server-query -execution-plans-viewing-plans / [ ^ ]
If you mean temporary indexes, then google can help: "create index in the stored procedures"[^]
But...if you are indexing values on a regular basis you should add them to your DB tables, not create them on the fly in your SP.
And if you think that creating them "on the fly" is going to be the solution, it's very likely that you need to examine exactly what your SP is doing, and how it does it - it's more likely to be a major design flaw there that explains why it takes so long to run. Start by looking at the execution plan. This may help: http://www.sqlshack.com/sql-server-query-execution-plans-viewing-plans/[^]


这篇关于如何在存储过程中创建索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆