SQLSERVER2012里的扩展事件初尝试(下) SQLSERVER2012里的扩展事件初尝试(上) 我们继续文章扩展事件在Denali CTP3里的新UI(二)里的这个实验 脚本文件下载: 我们打开上篇创建的blogtest扩展事件会话的属性 检查一下sql_statement_starting事件和sql_sta
SQLSERVER2012里的扩展事件初尝试(下)
SQLSERVER2012里的扩展事件初尝试(上)
我们继续文章扩展事件在Denali CTP3里的新UI(二)里的这个实验
脚本文件下载:
我们打开上篇创建的blogtest扩展事件会话的属性
检查一下sql_statement_starting事件和sql_statement_completed事件的谓词是不是database_name=’Northwind’
运行workload
大家可以看到instnwnd.sql这个文件是比较大的,执行的时候会产生一些workload
我们启动blogtest会话
然后执行instnwnd.sql脚本
如果你的机器运行这个脚本很长时间,你可以点击工具栏的“停止数据反馈”,SSMS会停止继续显示实时数据
实时数据窗口可能只有两个列name和timestamp,这是仅有的2个所有扩展事件共有的列
你可以选择工具栏上的选择列按钮,添加/删除需要显示的列
我增加了3个列database_name,duration和statement
我们要找到Northwind数据库里平均执行时间最长的query,首先我们可以过滤不必要的事件
上篇曾提到过谓词可以在SQL Server端避免不需要的事件被产生,我们同时也支持客户端的过滤器,这可以帮助你做各种分析
点击工具栏上的筛选器按钮,这将打开筛选器对话框
这里我们设置两个条件name=sql_statement_completed And database_name=Northwind
为了避免输入错误,你可以从事件列表里拷贝粘帖,你还可以右键点击某个单元格,然后选择Filter by this Value,
这将自动为你添加一个子句并And到原有条件上
设置完毕之后点击确定
过滤掉不必要的事件后我们按照statement来做分组,点击工具栏上的分组按钮
把statement移动到右边,点击确定
分组的目的是为了计算每个分组上duration的平均值,下面可以点击工具栏上的聚合按钮
我们在duration上聚合类型选择AVG
然后选择在duration(AVG)上按降序排序
这样duration平均值最大的分组将被显示在第一行
我执行instnwnd.sql的workload里duration最大的分组是“exec master.dbo.sp_MSdbuserpriv N'serv'”
它的duration是13610微秒,这样我们就找到了平均开销最大的query
我们用单位换算器换算一下
你可以通过 打开-》合并扩展事件文件-》来打开生成的xel文件
总结
大家一定会好奇,为什麽在创建事件会话的时候会有筛选器,在SSMS工具栏又有筛选器
其实扩展事件是属于SQLSERVER端的,,把SQLSERVER profiler的功能搬到SQLSERVER端,当然不是简单的搬到SQLSERVER端
而SSMS的工具栏只是提供一些分析xel文件的工具,这些跟SQLSERVER profiler是差不多的
比如人家给你一个xel文件,你需要SSMS的扩展事件工具栏的工具去分析
而以前SQLSERVER profiler是属于客户端的(是一个客户端工具),profiler获取SQLSERVER端的各种事件,然后传送回客户端,
在SQLSERVER profiler界面上显示给大家
所以大家可以理解为扩展事件就是把SQLSERVER profiler的功能集成到SQLSERVER端,反正我是这样理解的,不过这个集成不是简单的集成
如有不对的地方,欢迎大家拍砖o(∩_∩)o

MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
