分析SQL语句性能3种方法分享

来源:asp之家 时间:2012-06-06 20:09:30 

第一种方法:

代码如下:


Minimsdn.com为您提供的代码:
-- Turn ON [Display IO Info when execute SQL]
SET STATISTICS IO ON
-- Turn OFF [Display IO Info when execute SQL]
SET STATISTICS IO OFF


Link: http://msdn.microsoft.com/zh-cn/library/ms184361.aspx
第二种方法:

代码如下:


MINIMSDN.com为您提供的代码:
--Turn ON [Display detail info and the request for resources]
SET SHOWPLAN_ALL ON
-- Turn OFF [Display detail info and the request for resources]
SET SHOWPLAN_ALL OFF


Link: http://msdn.microsoft.com/zh-cn/library/ms187735
第三种方法:

Links: http://msdn.microsoft.com/zh-cn/library/ff650689.aspx ; http://msdn.microsoft.com/zh-cn/library/aa175244(v=SQL.80).aspx
Demo For three kinds of Method:
For SQL Script:

代码如下:


select * from dbEBMSStaging.dbo.MSSalesTxlatOrganizationMaster_Corg StagingOMC

v Its Execution plan: ()


v Its IO info: ()

- - You can try one table with 100/10000/1000000 rows but create/don't create Clustered/NONCLUSTERED Index.

v Its Detail info Etc.: ()


For SQL Script:


 代码如下:


select top 100 * from dbEBMSStaging.dbo.MSSalesTxlatOrganizationMaster_Corg StagingOMC


v Its Execution plan: ()

v Its IO info: ()

v Its Detail info Etc.: ()

For SQL Script:


代码如下:


select top 100 * from dbEBMSStaging.dbo.MSSalesTxlatOrganizationMaster_Corg StagingOMC
order by StagingOMC.COrgTPName


v Its Execution plan: ( )


v Its IO info: ()

v Its Detail info Etc.: ()

For SQL Script:


代码如下:


select top 100 StagingOMC.COrgTPName,COUNT(CorgID) from dbEBMSStaging.dbo.MSSalesTxlatOrganizationMaster_Corg StagingOMC
group by StagingOMC.COrgTPName
order by StagingOMC.COrgTPName


v Its Execution plan: ()


v Its IO info: ()

v Its Detail info Etc.: ()


- - By these three kinds of methods, you can try to check those words in the internet web are right or wrong about how to improve SQL Script performance.

标签:SQL语句,性能
0
投稿

猜你喜欢

  • Python基于traceback模块获取异常信息

    2022-04-27 11:30:10
  • linux环境下安装python虚拟环境及注意事项

    2023-12-09 08:02:47
  • 使用github部署前端vue项目

    2024-05-02 17:06:54
  • 各种SQL语句速查手册

    2007-09-27 19:31:00
  • Python编程pydantic触发及访问错误处理

    2021-05-19 20:49:07
  • Jupyter Notebook读入csv文件时出错的解决方案

    2021-09-15 18:13:48
  • 浅析Python pandas模块输出每行中间省略号问题

    2022-03-27 21:26:03
  • asp实现通过session来统计在线人数的方法

    2007-08-13 12:56:00
  • python通过exifread模块获得图片exif信息的方法

    2023-08-18 05:00:15
  • Java实现飞机大战-连接数据库并把得分写入数据库

    2024-01-26 19:16:54
  • 讲解Oracle数据库中结束死锁进程的一般方法

    2024-01-17 01:16:00
  • Python文件操作实战案例之用户登录

    2023-07-12 18:03:37
  • Python学习之迭代器详解

    2022-09-02 12:45:45
  • python绘制雷达图实例讲解

    2022-03-11 01:58:23
  • golang 对私有函数进行单元测试的实例

    2024-05-13 10:43:54
  • 使用Python处理KNN分类算法的实现代码

    2023-11-03 07:03:07
  • PHP日期和时间函数的使用示例详解

    2023-06-28 07:28:25
  • 如何通过阿里云实现动态域名解析DDNS的方法

    2022-05-30 23:04:50
  • 聊聊python里如何用Borg pattern实现的单例模式

    2021-06-26 23:28:38
  • 解决springboot yml配置 logging.level 报错问题

    2021-09-21 21:38:02
  • asp之家 网络编程 m.aspxhome.com