search
HomeDatabaseMysql TutorialOracle SQL tuning 数据库优化步骤图文教程

Oracle SQL tuning 数据库优化步骤图文教程

Jun 07, 2016 pm 04:20 PM
oracleoptimizationGraphics and textTutorialdatabasestep

SQL Turning 是Quest公司出品的Quest Central软件中的一个工具。Quest Central是一款集成化、图形化、跨平台的数据库管理解决方案,可以同时管理 Oracle、DB2 和 SQL server 数据库。 一、SQL Tuning for SQL Server简介 SQL语句的优化对发挥数据库的最佳性

   SQL Turning 是Quest公司出品的Quest Central软件中的一个工具。Quest Central是一款集成化、图形化、跨平台的数据库管理解决方案,可以同时管理 Oracle、DB2 和 SQL server 数据库。

  一、SQL Tuning for SQL Server简介

  SQL语句的优化对发挥数据库的最佳性能非常关键。然而不幸的是,应用优化通常由于时间和资源的因素而被忽略。SQL Tuning (SQL优化)模块可以对比和评测特定应用中SQL语句的运行性能,提出智能化的优化建议,帮助用户改善应用的响应时间。SQL优化模块具有非介入式SQL采集、自动优化和专家建议等功能,全面改善SQL优化工作。

  二、SQL Tuning for SQL Server的使用

  1、打开Quest Database Management Solutions弹出窗口如图1所示

Oracle SQL tuning 数据库优化步骤图文教程 三联

  图1

  2、在红色标记处打开SQL Tuning 优化SQL

  (1)建立连接。

  在Quest Central主界面上的“Database”树上选择“SQL Server”,然后在下方出现的“Tools”框中选择“SQL Tuning”选项,打开“Lanch SQL Tuning for SQL Server Connections”对话框(图2、图3)。我们在这里建立数据库服务器的连接,,以后的分析工作都会在它上面完成。

Oracle SQL tuning 数据库优化步骤图文教程

  图2 “建立连接”对话框

Oracle SQL tuning 数据库优化步骤图文教程

  图3

  双击“New Connection”图标,在弹出窗口中输入数据库的信息,单击“OK”,然后单击“Connect”即可。

  (2)分析原始SQL语句 ,在单击“Connect”后将弹出一个新窗口,如图4

Oracle SQL tuning 数据库优化步骤图文教程

  图4

  在打开窗口的“Oriangal SQL”文本框内输入需要分析的原始SQL语句,红色标记处选择对应的数据库名,SQL语句代码如下:

  图5 分析原始SQL语句

  原始SQL语句

  然后点击工具栏上的“Execute”按钮,执行原始的SQL语句,SQL Tuning会自动分析SQL的执行计划,并把分析结果显示到界面上(图5)。

Oracle SQL tuning 数据库优化步骤图文教程

  (3)优化SQL。

  现在我们点击工具栏上的“Optimize Statement”按钮,让SQL Tuning开始优化SQL,完成后,可以看到SQL Tuning产生了19条与原始SQL等价的优化方案(图6)。

Oracle SQL tuning 数据库优化步骤图文教程

  图6 SQL优化方案

  (4)获得最优SQL。

  接下来,我们来执行上面产生的优化方案,以选出性能最佳的等效SQL语句。在列表中选择需要执行的优化方案(默认已全部选中),然后点击工具栏上的“Execute”按钮旁边的下拉菜单,选择“Execute Selected”。等到所有SQL运行完成后,点击界面左方的“Tuning Resolution”按钮,

  可以看到最优的SQL已经出来啦,运行时间竟然可以提高21%!(图7)

Oracle SQL tuning 数据库优化步骤图文教程

  图7 “Tuning Resolution”界面

  最优的SQL语句如下:

  5)学习书写专家级的SQL语句 。

  优化后的SQL语句

  SELECT dbo.Person_BasicInfo.*,

  dbo.Graduater_GraduaterRegist.RegistNO AS RegistNO,

  dbo.Graduater_GraduaterRegist.RegistTime AS BaoDaoTime,

  dbo.Graduater_GraduaterRegist.RegistMan AS RegistMan,

  dbo.Graduater_Business.ComeFrom AS ComeFrom,

  dbo.Graduater_Business.Code AS Code,

  dbo.Graduater_Business.Status AS Status,

  dbo.Graduater_Business.ApproveResult AS ApproveResult,

  dbo.Graduater_Business.NewCorp AS NewCorp,

  dbo.Graduater_Business.CommendNumber AS CommendNumber,

  dbo.Graduater_Business.EmployStatus AS EmployStatus,

  dbo.Graduater_Business.NewCommendTime AS NewCommendTime,

  dbo.Graduater_Business.GetSource AS GetSource,

  dbo.Graduater_Business.EmployTime AS EmployTime,

  dbo.Graduater_Business.Job AS Job,

  dbo.Graduater_Business.FillMan AS FillMan,

  dbo.Graduater_Business.FillTime AS FillTime,

  dbo.Graduater_Business.IsCommendOK AS IsCommendOK,

  dbo.Graduater_Business.ApproveUser AS ApproveUser,

  dbo.Graduater_Business.ApproveTime AS ApproveTime,

  dbo.Graduater_Business.RegistTime AS RegistTime,

  dbo.Graduater_Business.EmployCorp AS EmployCorp,

  dbo.Graduater_Business.JobRemark AS JobRemark,

  CASE WHEN dbo.Graduater_Business.ComeFrom = 'WS' THEN '网上登记'

  WHEN dbo.Graduater_Business.ComeFrom = 'HP' THEN '华普大厦'

  WHEN dbo.Graduater_Business.ComeFrom = 'JD' THEN '精典大厦'

  WHEN dbo.Graduater_Business.ComeFrom = 'MC' THEN '赛马场'

  WHEN ComeFrom = 'ZX' THEN '高指中心' END AS ComeFromName,

  dbo.Person_Contact.Address AS Address,

  dbo.Person_Contact.Zip AS Zip,

  dbo.Person_Contact.Telephone AS Telephone,

  dbo.Person_Contact.Mobile AS Mobile,

  dbo.Person_Contact.Email AS Email,

  dbo.Person_Contact.IM AS IM,

  dbo.Person_Skill.ForeignLanguage AS ForeignLanguage,

  dbo.Person_Skill.ForeignLanguageLevel AS ForeignLanguageLevel,

  dbo.Person_Skill.CantoneseLevel AS CantoneseLevel,

  dbo.Person_Skill.MandarinLevel AS MandarinLevel,

  dbo.Person_Skill.Language AS Language,

  dbo.Person_Skill.TechnicalTitle AS TechnicalTitle,

  dbo.Person_Skill.ComputerLevel AS ComputerLevel,

  dbo.Person_EmployPurpose.JobType AS JobType,

  dbo.Person_EmployPurpose.Vocation AS Vocation,

  dbo.Person_EmployPurpose.JobPlace AS JobPlace,

  dbo.Person_EmployPurpose.Salary AS Salary,

  dbo.Person_EmployPurpose.OnJobDate AS OnJobDate,

  dbo.Person_EmployPurpose.CorpType AS CorpType,

  dbo.Person_EmployPurpose.Job AS RequireJob,

  YEAR(GETDATE()) - YEAR(dbo.Person_BasicInfo.Birthday) AS Age,

  dbo.Graduater_Business.EmployType AS EmployType,

  dbo.Graduater_Business.EmployTypeCode AS EmployTypeCode,

  dbo.Graduater_Business.EmployCorpType AS EmployCorpType,

  CASE WHEN dbo.Graduater_Business.PrintStatus = '已打印' THEN '已打印'

  ELSE '未打印' END AS PrintStatus,

  dbo.Graduater_Business.PrintTime AS PrintTime,

  CASE WHEN dbo.Graduater_Business.EmployStatus = '是' THEN '已就业'

  ELSE '未就业' END AS EmployStatusView

  FROM dbo.Person_BasicInfo

  INNER JOIN dbo.Graduater_Business

  ON dbo.Person_BasicInfo.PersonID = dbo.Graduater_Business.PersonID

  LEFT OUTER JOIN dbo.Graduater_GraduaterRegist

  ON dbo.Graduater_Business.GradBusinessID = dbo.Graduater_GraduaterRegist.GraduaterGUID

  INNER JOIN dbo.Person_Contact

  ON dbo.Person_BasicInfo.PersonID = dbo.Person_Contact.PersonID

  INNER JOIN dbo.Person_Skill

  ON dbo.Person_BasicInfo.PersonID = dbo.Person_Skill.PersonID

  INNER JOIN dbo.Person_EmployPurpose

  ON dbo.Person_BasicInfo.PersonID = dbo.Person_EmployPurpose.PersonID

  OPTION (FORCE ORDER)

  (

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Adding Users to MySQL: The Complete TutorialAdding Users to MySQL: The Complete TutorialMay 12, 2025 am 12:14 AM

Mastering the method of adding MySQL users is crucial for database administrators and developers because it ensures the security and access control of the database. 1) Create a new user using the CREATEUSER command, 2) Assign permissions through the GRANT command, 3) Use FLUSHPRIVILEGES to ensure permissions take effect, 4) Regularly audit and clean user accounts to maintain performance and security.

Mastering MySQL String Data Types: VARCHAR vs. TEXT vs. CHARMastering MySQL String Data Types: VARCHAR vs. TEXT vs. CHARMay 12, 2025 am 12:12 AM

ChooseCHARforfixed-lengthdata,VARCHARforvariable-lengthdata,andTEXTforlargetextfields.1)CHARisefficientforconsistent-lengthdatalikecodes.2)VARCHARsuitsvariable-lengthdatalikenames,balancingflexibilityandperformance.3)TEXTisidealforlargetextslikeartic

MySQL: String Data Types and Indexing: Best PracticesMySQL: String Data Types and Indexing: Best PracticesMay 12, 2025 am 12:11 AM

Best practices for handling string data types and indexes in MySQL include: 1) Selecting the appropriate string type, such as CHAR for fixed length, VARCHAR for variable length, and TEXT for large text; 2) Be cautious in indexing, avoid over-indexing, and create indexes for common queries; 3) Use prefix indexes and full-text indexes to optimize long string searches; 4) Regularly monitor and optimize indexes to keep indexes small and efficient. Through these methods, we can balance read and write performance and improve database efficiency.

MySQL: How to Add a User RemotelyMySQL: How to Add a User RemotelyMay 12, 2025 am 12:10 AM

ToaddauserremotelytoMySQL,followthesesteps:1)ConnecttoMySQLasroot,2)Createanewuserwithremoteaccess,3)Grantnecessaryprivileges,and4)Flushprivileges.BecautiousofsecurityrisksbylimitingprivilegesandaccesstospecificIPs,ensuringstrongpasswords,andmonitori

The Ultimate Guide to MySQL String Data Types: Efficient Data StorageThe Ultimate Guide to MySQL String Data Types: Efficient Data StorageMay 12, 2025 am 12:05 AM

TostorestringsefficientlyinMySQL,choosetherightdatatypebasedonyourneeds:1)UseCHARforfixed-lengthstringslikecountrycodes.2)UseVARCHARforvariable-lengthstringslikenames.3)UseTEXTforlong-formtextcontent.4)UseBLOBforbinarydatalikeimages.Considerstorageov

MySQL BLOB vs. TEXT: Choosing the Right Data Type for Large ObjectsMySQL BLOB vs. TEXT: Choosing the Right Data Type for Large ObjectsMay 11, 2025 am 12:13 AM

When selecting MySQL's BLOB and TEXT data types, BLOB is suitable for storing binary data, and TEXT is suitable for storing text data. 1) BLOB is suitable for binary data such as pictures and audio, 2) TEXT is suitable for text data such as articles and comments. When choosing, data properties and performance optimization must be considered.

MySQL: Should I use root user for my product?MySQL: Should I use root user for my product?May 11, 2025 am 12:11 AM

No,youshouldnotusetherootuserinMySQLforyourproduct.Instead,createspecificuserswithlimitedprivilegestoenhancesecurityandperformance:1)Createanewuserwithastrongpassword,2)Grantonlynecessarypermissionstothisuser,3)Regularlyreviewandupdateuserpermissions

MySQL String Data Types Explained: Choosing the Right Type for Your DataMySQL String Data Types Explained: Choosing the Right Type for Your DataMay 11, 2025 am 12:10 AM

MySQLstringdatatypesshouldbechosenbasedondatacharacteristicsandusecases:1)UseCHARforfixed-lengthstringslikecountrycodes.2)UseVARCHARforvariable-lengthstringslikenames.3)UseBINARYorVARBINARYforbinarydatalikecryptographickeys.4)UseBLOBorTEXTforlargeuns

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists

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.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.