简体   繁体   English

如何使用mysql减少存储过程中的执行时间

[英]How to reduce the execution time in stored procedure using mysql

i am working on asp.net3.5 and mysql, now my problem is search page enter the text click the search button fetch the records and bind the gridview , it taking more time(like 1min) but i can reduce the execution time how it possible in front end or back end please give me any idea about that. 我正在使用asp.net3.5和mysql,现在我的问题是搜索页面输入文本,单击搜索按钮获取记录并绑定gridview, 这需要花费更多时间(例如1分钟),但是我可以减少执行时间可能在前端或后端,请给我有关的任何想法。

thanking u hemanth 谢谢你的生命

For tuning the performance of a SP we need to know how much resources it is using and how much time it takes in execution. 为了调整SP的性能,我们需要知道它正在使用多少资源以及执行所需的时间。

1) Look the queries performence using Execution Plan. 1)使用执行计划查看查询性能。 After find the Queries, just check the Index(for table used in query) and look the join conditions between tables in the query. 找到查询后,只需检查索引(用于查询的表)并查看查询中表之间的联接条件。 - This is way we need to approch to tune the SP. -这是我们需要调整SP的方式。

2) we need to use tablename with (nolock) in our select statements so that it does not create delay if other person is updating the table at the same time it will show last updated table recordset 2)我们需要在select语句中使用带有(nolock)的表名,以便在其他人同时更新表的同时不会显示延迟,因为它将显示最后更新的表记录集

3) if we dont need that much the database server to return the number of records affected after executing any dml statements which actually reduces the performance ,we can use set nocount on -set nocount off before and after writing the sql query, 3)如果执行任何dml语句后实际上不需要太多的数据库服务器来返回受影响的记录数,这实际上会降低性能,我们可以在编写sql查询之前和之后使用set nocount on -set nocount off,

4) we can create lesser join statements if we can use subqueries 4)如果可以使用子查询,则可以创建较少的join语句

  • Try getting lesser values on front end. 尝试在前端获得较小的值。
  • Try getting them using AJAX which are Ajax benifit 尝试使用Ajax的受益者 AJAX来获取它们
  • Try optimizing your SQL QUERY 尝试优化您的SQL查询

This link will guide how Store Procedure Reduces Time 此链接将指导存储过程如何减少时间

Without any sample code, there's not much we can work on. 没有任何示例代码,我们将无能为力。 But since you asked for ideas ... 但是既然你想出主意 ...

I can think of two possible reasons why your page loads slow: 我可以想到页面加载缓慢的两个可能原因:

  1. SQL side of things - Teez basically said what needs to be said. SQL方面的东西-Teez基本上说了需要说的东西。
  2. Display of results - How are you binding to the gridview? 显示结果-如何绑定到gridview? Are there extra database calls when you're binding? 绑定时是否有额外的数据库调用? Are you performing pagination? 您正在执行分页吗? How? 怎么样?

You can improve performance by optimizing your query. 您可以通过优化查询来提高性能。

  • Select only relevant columns instead of select * 只选择relevant columns而不是select *

  • Use Join if large number of records are there other wise use sub query (For such cases) 如果有大量记录,则使用Join,否​​则明智地使用子查询(对于这种情况)

Query Optimization 查询优化

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

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