使用索引调节向导调整应用程序的性能_MySQL
你可以使用SQL服务器调节器(SQL Server Profiler)工具来收集服务器当前活动的重要信息。被这个Profiler工具所追踪到的信息(包含有数据库的真实负载)能够被用在多种场合里。现在让我们来看看如何使用Profiler收集能够被索引调节向导所使用的数据,以及你该如何使用这些工具来调试你的应用程序。
什么时候使用它?
Profiler工具能够用在数据库开发生命周期的所有阶段。例如,在初始阶段,你可以用它来辅助调试或者查明你的应用程序应该如何以及在何时调用存储过程和其他的SQL声明。在我最近所参与的一个项目里,一个已编译组件一调用数据库就超时,在这种情况下,我们使用了Profiler来辨别SQL的声明和应用程序调用它们的顺序。使用这个工具就帮助我们发现了逻辑上的错误,这样我们就成功地更正了自己的应用程序。
在开发过程后面的阶段里,Profiler能够有助于辨别负载/压力测试(load/stress testing)过程中应用程序的瓶颈。你还可以用它来监视日常的活动、执行安全审查,以及辨别其他影响性能的因素(例如设计不佳的查询)。
在Profiler里,你必须决定要记录什么,并考虑将所记录下来的服务器活动应该被保存在哪里。你可以选择将自己的追踪信息保存到数据库表格里或者是文件里。当选择将捕捉到的数据保存到表格里的时候,你还可以设置要保存数据行的最大数量。这样,Profiler就能够在一个任务繁重的系统里迅速地捕捉大量数据。但是由于这一点,你可能想要限制在一次追踪之中Profiler所要捕捉的数据总量。
你可以选择将所获得的信息保存到追踪文件里。如果选择了这个选项,你就能够在文件达到了一定的大小之后将文件信息覆盖掉,这将限制捕捉信息文件大小的上限。而且,你可以选择要从哪里开始进行追踪处理。这就非常像在应用程序层里编写代码选择是在客户端还是在服务器端进行指针执行。在正式的产品系统里,你可能不希望在服务器上放上这么一个工作负载,这样的话,让客户端处理可能就是最好的选择了。
当在这两个选项之间进行选择的时候,你的主要注意力应该放在其对数据库/应用程序性能的影响上。对于大多数类型的日志记录工作而言,将其保存为文件对系统的负担要比保存到数据库的小,所以对于高流量的实际产品系统来说,将日至保存为文件可能是更好的选择。
使用Profiler
你可以使用Profiler创建和保存能够被索引调节向导所使用的追踪结果。为了使用Profiler为向导所收集到的数据,你可以选择SQL服务器自带的缺省模板。要做到这一点,在文件(File)菜单里选择新建|追踪(New | Trace)。在常规(General)选项卡里(图A)选择用于向导的缺省模板。你就会看到可以将追踪结果保存为文件或者到数据库里。
图A
Profiler的常规选项卡
在事件(Events)选项卡里(图B),和向导相关联的事件类型有两个:RPC:Completed用于存储过程,以及SQL:BatchCompleted用于其他的TSQL声明。
图B
Profiler的事件选项卡
在使用调节器对SQL服务器的活动进行捕捉的时候,你会在一段相对较短的时间内获得大量的数据,这取决于你服务器的使用情况。所以你就应该选择只记录下你所需要的项目而不是修改缺省的模板。而且在运行Profiler的时候,你要确保在捕捉期间典型的应用程序活动会发生,这对于保证索引调节向导的质量是非常重要的,除非你是正在试图解决某个特定的问题,在后面这种情况下你要确信指定的事件正在发生。
一旦追踪被保存到文件里或者数据库表格里,你就可以回放这一过程中所发生的所有活动——设置你希望的断点——这和你使用开发人员的IDE调试器很类似,如图C所示。
图C
回放Profiler的追踪内容
再次强调,捕捉到的数据会是相当多的。为了帮助限制所捕捉数据的数量,你可以定义过滤器。在定义自己的过滤器(图D)时,设置时间较长的查询是很常见的。
图D
过滤数据
Profiler还能记录许多其他类型的数据库活动。Profiler本身就有许多选项供你选择。要获得更多的信息,我建议去查询MSDN在线或者SQL服务器的文档。Profiler会成为任何DBA的朋友,另外我还建议你去考察一下它的其他许多选项。

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The Apple Vision Pro headset is not natively compatible with computers, so you must configure it to connect to a Windows computer. Since its launch, Apple Vision Pro has been a hit, and with its cutting-edge features and extensive operability, it's easy to see why. Although you can make some adjustments to it to suit your PC, and its functionality depends heavily on AppleOS, so its functionality will be limited. How do I connect AppleVisionPro to my computer? 1. Verify system requirements You need the latest version of Windows 11 (Custom PCs and Surface devices are not supported) Support 64-bit 2GHZ or faster fast processor High-performance GPU, most

Having issues with the Shazam app on iPhone? Shazam helps you find songs by listening to them. However, if Shazam isn't working properly or doesn't recognize the song, you'll have to troubleshoot it manually. Repairing the Shazam app won't take long. So, without wasting any more time, follow the steps below to resolve issues with Shazam app. Fix 1 – Disable Bold Text Feature Bold text on iPhone may be the reason why Shazam is not working properly. Step 1 – You can only do this from your iPhone settings. So, open it. Step 2 – Next, open the “Display & Brightness” settings there. Step 3 – If you find that “Bold Text” is enabled

Windows 10 vs. Windows 11 performance comparison: Which one is better? With the continuous development and advancement of technology, operating systems are constantly updated and upgraded. As one of the world's largest operating system developers, Microsoft's Windows series of operating systems have always attracted much attention from users. In 2021, Microsoft released the Windows 11 operating system, which triggered widespread discussion and attention. So, what is the difference in performance between Windows 10 and Windows 11? Which

MetaMask (also called Little Fox Wallet in Chinese) is a free and well-received encryption wallet software. Currently, BTCC supports binding to the MetaMask wallet. After binding, you can use the MetaMask wallet to quickly log in, store value, buy coins, etc., and you can also get 20 USDT trial bonus for the first time binding. In the BTCCMetaMask wallet tutorial, we will introduce in detail how to register and use MetaMask, and how to bind and use the Little Fox wallet in BTCC. What is MetaMask wallet? With over 30 million users, MetaMask Little Fox Wallet is one of the most popular cryptocurrency wallets today. It is free to use and can be installed on the network as an extension

Xiaomi car software provides remote car control functions, allowing users to remotely control the vehicle through mobile phones or computers, such as opening and closing the vehicle's doors and windows, starting the engine, controlling the vehicle's air conditioner and audio, etc. The following is the use and content of this software, let's learn about it together . Comprehensive list of Xiaomi Auto app functions and usage methods 1. The Xiaomi Auto app was launched on the Apple AppStore on March 25, and can now be downloaded from the app store on Android phones; Car purchase: Learn about the core highlights and technical parameters of Xiaomi Auto, and make an appointment for a test drive. Configure and order your Xiaomi car, and support online processing of car pickup to-do items. 3. Community: Understand Xiaomi Auto brand information, exchange car experience, and share wonderful car life; 4. Car control: The mobile phone is the remote control, remote control, real-time security, easy

Ollama is a super practical tool that allows you to easily run open source models such as Llama2, Mistral, and Gemma locally. In this article, I will introduce how to use Ollama to vectorize text. If you have not installed Ollama locally, you can read this article. In this article we will use the nomic-embed-text[2] model. It is a text encoder that outperforms OpenAI text-embedding-ada-002 and text-embedding-3-small on short context and long context tasks. Start the nomic-embed-text service when you have successfully installed o

Performance comparison of different Java frameworks: REST API request processing: Vert.x is the best, with a request rate of 2 times SpringBoot and 3 times Dropwizard. Database query: SpringBoot's HibernateORM is better than Vert.x and Dropwizard's ORM. Caching operations: Vert.x's Hazelcast client is superior to SpringBoot and Dropwizard's caching mechanisms. Suitable framework: Choose according to application requirements. Vert.x is suitable for high-performance web services, SpringBoot is suitable for data-intensive applications, and Dropwizard is suitable for microservice architecture.

The performance comparison of PHP array key value flipping methods shows that the array_flip() function performs better than the for loop in large arrays (more than 1 million elements) and takes less time. The for loop method of manually flipping key values takes a relatively long time.
