SQL优化 [英] SQL OPTIMIZATION

查看:72
本文介绍了SQL优化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有8个表的简单sql查询,其中3个表有30、60和80万条记录
我已将内部联接应用于显示了35万条记录的表,但是要显示这些记录需要花费大量时间.
我已经在where子句中使用的日期列上应用了索引,并且还对有数十万条记录的表的主键应用了索引.
对于 where 子句中的日期列,而不是之间,我使用了大于等于(>)" 小于等于(<)" 运算符.
除了上述步骤之外,我还可以采用其他什么步骤来提高查询的性能.

I have simple sql query with 8 tables of which 3 tables have 30, 60 and 80 lakhs of records
I have applied inner joins on tables to which 35 lakhs of records of displayed but to display these records its takes hell lot of time.
I have applied index on the date column used in where clause and have also applied index on primary keys of the tables having lakhs of records.
for date column in where clause instead of between I have used "greater than equal to (>)" and "less than equal to (<)" operator.
Apart from above steps what other steps can I apply to improve the performance of the query.

推荐答案

您可以尝试在date where子句中使用BETWEEN语句.不知道这与您所拥有的执行之间的成本差异是多少.它是一种替代方法:)例如

在"firstdate"和"seconddate"之间的"datecol"
You could try using a BETWEEN statement in the date where clause. Don''t know what the cost difference is in the execution between that and what you have. its an alternative though :) e.g.

WHERE ''datecol'' BETWEEN ''firstdate'' AND ''seconddate''


这篇关于SQL优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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