oracle 9i tuning sql2
Oracle 9i 数据库性能调优技术-les02
Maintenance of the Alert Log File
• •
The alert log file consists of a chronological log of messages and errors. Check the alert log file regularly to:
2-21
Copyright © Oracle Corporation, 2002. All rights reserved.
Tuning Using Oracle Expert
2-14
Copyright © Oracle Corporation, 2002. All rights reserved.
Statspack
• • • • •
Installation of Statspack using the spcreate.sql script Collection of statistics execute statspack.snap Automatic collection of statistics using the spauto.sql script Produce a report using the spreport.sql script To collect timing information, set TIMED_STATISTICS = True
2-7
Copyright © ll rights reserved.
Oracle Enterprise Manager Console
2-9
Oracle Server X9-2L 数据表说明书
Oracle Server X9-2LOracle Server X9-2L is the ideal 2U platform for databases, enterprise storage, and big data solutions. Supporting the standard and enterprise editions of Oracle Database, this server delivers best-in-class database reliability in single-node configurations. With support for up to 132.8 TB of high-bandwidth NVM Express (NVMe) flash storage, Oracle Database using its Database Smart Flash Cache feature, as well as NoSQL and Hadoop applications can be significantly accelerated. Optimized for compute, memory, I/O, and storage density simultaneously, Oracle Server X9-2L delivers extreme storage capacity at lower cost when combined with Oracle Linux, or Oracle Solaris with ZFS file system compression. Each server comes with built-in, proactive fault detection and advanced diagnostics, along with firmware that is already optimized for Oracle software, to deliver extreme reliability.Product OverviewOracle Server X9-2L is a two-socket server designed and built specifically for the demands of enterprise workloads. It is a crucial building block in Oracle engineered systems and Oracle Cloud Infrastructure. Powered by one Platinum, two Gold, or one Silver Intel® Xeon® Scalable Processor Third Generation models with up to 32 cores per socket, along with 32 memory slots, this server offers high-performance processors plus the most dense flash storage options in a 2U enclosure. Oracle Server X9-2L is the most balanced and highest performing 2U enterprise server in its class because it offers optimal core and memory density combined with high I/O throughput.In addition to optimized processing power and storage density, Oracle ServerX9-2L offers 10 PCIe 4.0 expansion slots (two 16-lane and eight 8-lane) for maximal I/O card and port density. With 576 gigabytes per second of bidirectional I/O bandwidth, Oracle Server X9-2L can handle the most demanding enterprise workloads.Oracle Server X9-2L offers best-in-class reliability, serviceability, and availability (RAS) features that increase overall uptime of the server. This extreme reliability makes Oracle Server X9-2L the best choice for single-node Oracle Database deployments in remote or branch office locations. Real-time monitoring of the health of the CPU, memory, and I/O subsystems, coupled with off lining capability of failed components, increases the system availability. Building on the firmware-level problem detection, Oracle Linux and Oracle Solaris are enhanced to provide fault detection capabilities when running on Oracle Server X9-2L. In Key FeaturesMost flash-dense andenergy-efficient 2Uenterprise-class serverTwo Intel® Xeon® Scalable Processor Third GenerationCPUsThirty-two DIMM slots with maximum memory of 2 TB Ten PCIe Gen 4 slotsUp to 216 TB SAS-3 disk storage in 12 slots instandard configurationsUp to 132.8 TB NVM Express high-bandwidth all-flashconfigurationOracle Integrated Lights Out Manager (ILOM)Key BenefitsReduce vulnerability tocyberattacksAccelerate Oracle Database, NoSQL, and Hadoopapplications using Oracle’sunique NVM Express design Satisfy demands ofenterprise applications withextreme I/O card densityIncrease uptime with built-in diagnostics and faultdetection from Oracle Linuxand Oracle SolarisIncrease storage capacity 15x compared to previousgeneration, combiningextreme compute power with Oracle Solaris and ZFScompressionMaximize system power efficiency with OracleAdvanced System CoolingMaximize IT productivity by running Oracle software onOracle hardwareaddition, exhaustive system diagnostics and hardware-assisted error reporting and logging enable identification of failed components for ease of service.To help users achieve accelerated performance of Oracle Database, Oracle Server X9-2L supports hot-swappable, high-bandwidth flash that combines with Database Smart Flash Cache to drive down cost per database transaction. In the all-flash configuration, with Oracle’s unique NVM Express design, Oracle Server X9-2L supports up to 12 small form factor NVMe drives and up to eight NVMe add-in cards, for a total capacity of 132.8 TB. This massive flash capacity also benefits NoSQL and Hadoop applications, reducing network infrastructure needs and accelerating performance with 120 GB per second of total NVMe bidirectional bandwidth.For maximizing storage capacity, Oracle Server X9-2L is also offered in a standard 12-disk configuration, with 3.5-inch large form factor disk slots accommodating high-capacity hard disk drives (HDDs). A maximum 216 TB of direct-attached storage makes Oracle Server X9-2L ideally suited as a storage server. The compute power of this server can be used to extend storage density even further with Oracle Solaris and ZFS file system compression to achieve up to 15x compression of data without significant performance impact. Oracle Server X9-2L is also well suited for other storage-dense implementations, such as video compression and transcoding, which require a balanced combination of compute power and storage capacity at the same time.Oracle Server X9-2L ships with Oracle ILOM 5.0, a cloud-ready service processor designed for today's security challenges. Oracle ILOM provides real-time monitoring and management of all system and chassis functions as well as enables remote management of Oracle servers. Oracle ILOM uses advanced service processor hardware with built-in hardening and encryption as well as improved interfaces to reduce the attack surface and improve overall security. Oracle ILOM has improved firmware image validation through the use of improved firmware image signing. This mechanism provides silicon-anchored service processor firmware validation that cryptographically prevents malicious firmware from booting. After Oracle ILOM's boot code is validated by the hardware, a chain of trust allows each subsequent firmware component in the boot process to be validated. Finally, with a focus on security assurance, using secure coding and testing methodologies, Oracle is able to maximize firmware security by working to prevent and remediate vulnerabilities prior to release. With advanced system cooling that is unique to Oracle, Oracle Server X9-2L achieves system efficiencies that result in power savings and maximum uptime. Oracle Advanced System Cooling utilizes remote temperature sensors for fan speed control, minimizing power consumption while keeping optimal temperatures inside the server. These remote temperature sensors are designed into key areas of this server to ensure efficient fan usage by organizing all major subsystems into cooling zones. This technology helps reduce energy consumption in a way that other servers cannot.Oracle Premier Support customers have access to My Oracle Support and multi-server management tools in Oracle Enterprise Manager, a critical component that enables application-to-disk system management including servers, virtual Key ValueOracle Server X9-2L is the most storage-dense, versatile two-socket server in its class for the enterprise data center, packing the optimal balance of compute power, memory capacity, and I/O capacity into a compact and energy-efficient 2U enclosure. Related productsOracle Server X9-2Oracle Server X8-8Related servicesThe following services are available from Oracle Customer Support:SupportInstallationEco-optimization servicesmachines, databases, storage, and networking enterprise wide in a single pane of glass. Oracle Enterprise Manager enables Exadata, database, and systems administrators to proactively monitor the availability and health of their systems and to execute corrective actions without user intervention, enabling maximum service levels and simplified support.With industry-leading in-depth security spanning its entire portfolio of software and systems, Oracle believes that security must be built in at every layer of the IT environment. In order to build x86 servers with end-to-end security, Oracle maintains 100 percent in-house design, controls 100 percent of the supply chain, and controls 100 percent of the firmware source code. Oracle’s x86 servers enable only secure protocols out of the box to prevent unauthorized access at point of install. For even greater security, customers running Oracle Ksplice on Oracle’s x86 servers will benefit greatly from zero downtime patching of the Oracle Linux kernel.Oracle is driven to produce the most reliable and highest performing x86 systems in its class, with security-in-depth features layered into these servers, for two reasons: Oracle Cloud Infrastructure and Oracle Engineered Systems. At their foundation, these rapidly expanding cloud and converged infrastructure businesses run on Oracle’s x86 servers. To ensure that Oracle’s SaaS, PaaS, and IaaS offerings operate at the highest levels of efficiency, only enterprise-class features are designed into these systems, along with significant co-development among cloud, hardware, and software engineering. Judicious component selection, extensive integration, and robust real-world testing enable the optimal performance and reliability critical to these core businesses. All the same features and benefits available in Oracle’s cloud are standard in Oracle’s x86 standalone servers, helping customers to easily transition from on-premises applications to cloud with guaranteed compatibility and efficiency.Oracle Server X9-2L System SpecificationsCache•Level 1: 32 KB instruction and 32 KB data L1 cache per core•Level 2: 1 MB shared data and instruction L2 cache per core•Level 3: up to 1.375 MB shared inclusive L3 cache per coreMain Memory•Thirty-two DIMM slots provide up to 2 TB of DDR4 DIMM memory•RDIMM options: 32 GB or 64 GB at DDR4-3200 dual rankInterfaces Standard I/O•One 1000BASE-T network management Ethernet port•One 1000BASE-T host management Ethernet port•One RJ-45 serial management port•One rear USB 3.0 port•Expansion bus: 10 PCIe 4.0 slots, two x16 and eight x8 slots•Supports LP-PCIe cards including Ethernet, FC, SAS and flashStorage•Twelve 3.5-inch front hot-swappable disk bays plus two internal M.2boot drives•Disk bays can be populated with 3.5-inch 18 TB HDDs or 2.5-inch 6.8 or 3.84 NVMesolid-state drives (SSDs)•PCIe flash•Sixteen-port 12 Gb/sec RAID HBA supporting levels: 0, 1, 5, 6, 10, 50, and 60 with 1GB of DDR3 onboard memory with flash memory backup via SAS-3 HBA PCIe cardHigh-Bandwidth Flash•All flash configuration—up to 132.8 TB in the all-flash configuration (maximum of12 hot-swappable 6.8 TB NVMe SSDs and eight 6.4 TB NVMe PCIe cards)NVMe functionality in 3.5-inch disk bays 8-11 requires an Oracle NVMeretimer that is installed in PCIe slot 10Systems Management Interfaces•Dedicated 1000BASE-T network management Ethernet port (10/100/1000 Gb/sec)•One 1000BASE-T host management Ethernet port (10/100/1000 Gb/sec)•In-band, out-of-band, and side-band network management access•One RJ-45 serial management portService ProcessorOracle Integrated Lights Out Manager (Oracle ILOM) provides:•Remote keyboard, video, and mouse redirection•Full remote management through command-line, IPMI, and browser interfaces•Remote media capability (USB, DVD, CD, and ISO image)•Advanced power management and monitoring•Active Directory, LDAP, and RADIUS support•Dual Oracle ILOM flash•Direct virtual media redirection•FIPS 140-2 mode using OpenSSL FIPS certification (#1747)Monitoring•Comprehensive fault detection and notification•In-band, out-of-band, and side-band SNMP monitoring v2c and v3•Syslog and SMTP alerts•Automatic creation of a service request for key hardware faults with Oracleautomated service request (ASR)Oracle Enterprise Manager•Advanced monitoring and management of hardware and software•Deployment and provisioning of databases•Cloud and virtualization management•Inventory control and patch management•OS observability for performance monitoring and tuning•Single pane of glass for management of entire Oracle deployments, including onpremises and Oracle CloudSoftware Operating Systems•Oracle Linux•Oracle SolarisVirtualization•Oracle KVMFor more information on software go to: Oracle Server X9-2L Options & DownloadsOperating Environment •Ambient Operating temperature: 5°C to 40°C (41°F to 104°F)•Ambient Non-operating temperature: -40°C to 68°C (-40°F to 154°F)•Operating relative humidity: 10% to 90%, noncondensing•Non-operating relative humidity: up to 93%, noncondensing•Operating altitude: Maximum ambient operating temperature is derated by 1°C per 300 m of elevation beyond 900 m, up to a maximum altitude of 3000 m•Non-operating altitude: up to 39,370 feet (12,000 m)•Acoustic noise-Maximum condition: 7.1 Bels A weightedIdle condition: 7.0 Bels A weightedConnect with usCall +1.800.ORACLE1 or visit . Outside North America, find your local office at: /contact. /oracle /oracleCopyright © 2023, Oracle and/or its affiliates. All rights reserved. This document is provided for information purposes only, and the contents hereof are subject to change without notice. This document is not warranted to be error-free, nor subject to any other warranties or conditions, whether expressed orally or implied in law, including implied warranties and conditions of merchantability or fitness for a particular purpose. We specifically disclaim any liability with respect to this document, and no contractual obligations are formed either directly or indirectly by this document. This document may not be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without our prior written permission.This device has not been authorized as required by the rules of the Federal Communications Commission. This device is not, and may not be, offered for sale or lease, or sold or leased, until authorization is obtained.Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group. 0120Disclaimer: If you are unsure whether your data sheet needs a disclaimer, read the revenue recognition policy. If you have further questions about your content and the disclaimer requirements, e-mail ********************.。
Oracle9i的多种连接语法
Oracle9i的简化SQL语法(含连接)Oracle对Oracle9i SQL 做了一些很重要的改进,包括一些令人兴奋的新特点,支持1:5的数量级和ISO99中的SQL标准。
作为Oracle的补充,它包括以下新的TABLE JOIN的句法结构:CROSS IN——它在两个表格中创建了一个卡迪尔列,就象是在Oracle8i中没写WHERE 时那样。
NA TURAL JOIN——这是一个很有用的Oracle9i的句法,它通过从WHERE子句中移动连接标准来改善SQL的稳定性USING子句——它可以通过名字来具体指定连接ON子句——这个句法允许在两个表格中为连接具体指定栏目的名头LEFT OUTER JOIN——它返回表格中左边的行和右边的数值,如果没有搭配的行的话,则返回空//我刚才试过了,left (outer) join等这种连接的语法,在oracle9i的版本中开始支持了,我在oracle中试了一下,是可以的,所以可以放心地用连接了。
也就是说在oracle9中,以下两种方法都是正确的:select * from test,test1 where test.ID(+) = test1.ID;select * from test1 left join test on test1.ID = test.ID;RIGHT OUTER JOIN——它返回表格中右边的行和左边的数值,如果没有搭配的行的话,则返回空FULL OUTER JOIN——它返回的是两个表格中所有的行,用空填满每一个空格。
这在Oracle8i中则没有相应的此种句法大多数改进都是为了让那些非Oracle的请求以快速的进入Oracle数据库而引进的,并且必须记住这些只是句法上的不同,ISO99标准并没有给Oracle9i SQL带来任何新的功能。
The CROSS JOIN在Oracle中,CROSS JOIN产生了一个“卡迪尔的产物(Cartesian product)”,就象是在连接两个表格时忘记加入一个WHERE子句一样select last_name,dept_idfrom emp,depts;在Oracle9i中,我们使用CROSS JOIN 来达到相同的结果select last_name.dept_idfrom empCROSS JOIN dept;NA TURAL JOIN我喜欢NATURAL JOIN的原因在于它能够通过在两个表格中配对的栏目的名头来自动的检查join。
Oracle 9i 整体性能优化概述草稿之一 调整争用
2.2.2是否存在latch争用
select event,total_waits,time_waited
from v$system_event
where event = ‘latch free’;
如:
EVENT TOTAL_WAITS TIME_WAITED
---------- ----------- -----------
? library cache:需要优化library cache。
? cache buffers LRU chain:管理database cache buffers上的LRU List上的块,自由缓冲区列表。此争用有两种可能:
- 导致严重的全部扫描的SQL语句或执行计划。SQL需要优化。
- 脏缓冲区写盘database writer未能跟上I/O请求。优化磁盘I/O。
比如如果应用程序有许多频繁插入行的用户,在试图访问该表的free list就可能会经历等待。
2.3.2是否存在free list争用
select event,total_waits,time_waited from v$system_event
where event = ‘buffer busy waits’;
而lock,在遇到问题的时候,可作为维护参考,平时不进行太多的维护(或从应用上考虑优化)。(除了定期去$ORACLE_HOME/admin/$ORACLE_SID/udump查看死锁情况外)
2.2诊断latch竞争
2.2.1概念
Latch是简单的、低层次的序列化技术,用以保护SGA中的共享数据结构,比如并发用户列表和buffer cache里的blocks信息。一个服务器进程或后台进程在开始操作或寻找一个共享数据结构之前必须获得对应的latch,在完成以后释放latch。不必对latch本身进行优化,如果latch存在竞争,表明SGA的一部分正在经历不正常的资源使用。
Oracle 9i完美安装、配置及操作
Oracle 9i完美安装、配置及操作一、说明:1. 准备工作通过解压后在硬盘上形成与三张光盘相关的三个子目录,它们是92010NT_Disk1、92010NT_Disk2、92010NT_Disk3目录,通过三个子目录可以制作成带有三张光盘的Oracle 9i软件。
2 安装数据库服务器(1)将Oracle9i的第一张光盘插入光驱,系统将自动运行Oracle 9i的安装程序,出现如图1所示的启动安装窗口,单击【开始安装】字样,相继出现如图2版本窗口和3的欢迎窗口。
在图3中单击【下一步】按钮。
图1 启动安装图2 Oracle版本图3 欢迎使用(2)出现如图所示的文件定位窗口。
此窗口主要指出源文件和目标文件的位置,按照默认即可,单击【下一步】按钮。
(3)安装程序将有一段时间做加载产品的工作,然后出现如图所示的可用产品窗口。
共有三个选项。
安装数据库服务器时,选中【Oracle9i Database 9.2.0.1.0】单选钮,单击【下一步】按钮。
(4)出现如图所示的安装类型窗口。
共有四个选项。
选中【企业版】单选钮,单击【下一步】按钮。
(5)出现如图所示的数据库配置窗口。
共有五个选项。
选中【通用】单选钮,单击【下一步】按钮。
(6)出现如图所示的Oracle事务恢复服务配置窗口。
在窗口中需要输入一个端口号,默认为2030。
保持默认值,单击【下一步】按钮。
(7)出现如图所示的数据库标识窗口。
共有两个参数。
全局数据库名:Oracle9i是分布式数据库系统,因此要求用全局数据库名唯一标识。
全局数据库名由数据库名和域名组成。
通常的形式为“name.domain”。
其中,name是数据库名,domain是数据库所在的网络域名。
SID:数据库系统标识符,是System Identifer的英文缩写。
主要用于区分同一台计算机上安装的不同的数据库例程。
在全局数据库名文本框里输入“”,单击【下一步】按钮。
(8)出现如图所示的数据文件位置窗口。
oracle各个版本之间的区别
Oracle的各个版本之间的区别一、Oracle 9i比8i多了哪些新特性?1、并发集群,8i OPS升级为9i RAC,8i结点间用硬盘交换信息,9i结点间采用高速网线的缓存熔合(Cache Fusion)技术交换信息,交换速度提高100倍以上。
2、9i可以在线修改内核参数和内存分配,8i不行。
数据文件和表空间管理,8i手工管理,9i自动管理。
3、9i比8i增强了对ANSI SQL99的支持。
4、9i比8i增强了故障后的快速恢复(Fast-start)。
5、8i只支持物理备份(physical backup)数据库,9i还增加了支持逻辑备份(logical backup)数据库,使备份数据库除了作为主数据库的镜像外,还可以提供其他数据服务.二、Oracle 10g比9i多的新特性?1. 10g支持网格计算,即多台结点服务器利用高速网络组成一个虚拟的高性能服务器,负载在整个网格中衡(Load Balance),按需增删结点,避免单点故障(Single Point of Faliure)2.10g容易安装,且安装速度比9i少了一半3.新增基于浏览器的企业管理器(Enterprise Manager)。
4.支持自动管理(Automatic Management)增删硬盘不再需要操作系统管理员设置的镜像、负载均衡物理卷、逻辑卷、分区、文件系统,只要打一条Oracle命令,ASM会自动管理增加或删除的硬盘。
5.内存自动化,根据需要自动分配和释放系统内存。
6.SQL性能调整自动化。
7.快速纠正人为错误的闪回(Flashback)查询和恢复,可以恢复数据库、表甚至记录。
8.数据泵(Data Pump)高速导入、导出数据,比传统方法导出速度快两倍以上,导入速度快15--45倍.9.精细审计(Fine-Grained Auditing),记录一切对敏感数据的操作10.存储数据的表空间(Tablespace)跨平台复制,极大的提高数据仓库加载速度。
Oracle 9i SQL优化快速手册V1.00
Oracle 9i SQL优化快速手册——蒋红腥1概述《Oracle 9i数据库SQL优化快速手册》并不全面讲解Oracle9i SQL优化技术,也不具体分析各种优化方法的原理,旨在通过简单明显有效的调整方法,帮助程序员或维护人员在开发、维护过程中,针对执行速度极慢的Oracle数据库开发操作,快速取得更快、更好的执行效果。
此时优化的结果并不是最优的,但我们的目标是能快速满足我们操作数据库的需求即可。
若想取得更多的SQL优化效果,请参考附件《Oracle 9i SQL语句调整》。
若要取得尽可能多的优化效果,则需要参考有关书籍,从Oracle服务器级优化、网络级优化、内存级优化以及优化器-SQL 优化等等入手进行综合优化。
下文中使用的方法,并不是完全规范的,合理的,但为求简单、方便快速的满足一般应用,一些设置采用了推荐设置、默认设置,直接按照说明操作,即可获得大多数的明显的优化结果。
2简易优化过程根据执行计划,通过添加索引,使用CBO提示等优化方式,调整执行计划,达到满足需求。
前提条件:已知那些执行语句慢。
2.1第一步:准备优化调试环境⏹使用windows自带的command,打开2个窗口登陆到数据库服务器。
⏹设置查看“执行计划环境command窗口”。
在其中一个以$sqlplus “/as sysdba”方式登陆的SQL提示符下执行如下命令:SQL>set autotrace traceonly explainSQL>⏹设置“调试SQL语句窗口”。
在另一个command窗口使用执行该语句的用户登陆;执行该语句,记录执行时间。
如:$sqlplus perf/perf@omcdbSQL> set timing on ---设置SQL执行时间记录返回--- 照着执行SQL>alter session set optimizer_index_cost_adj=30; --- 照着执行SQL>alter session set optimizer_index_caching=40; --- 照着执行SQL>执行返回的时间格式说明,如:已用时间: 00: 00: 00.04 小时:分:秒.微秒2.2第二步:查看SQL语句执行计划在“执行计划环境command窗口”中,执行被调试的SQL语句,此时会输出该语句的执行计划,如下所示:(在from table的table表名前,添加该表的所属用户名)如上图所示,兰色部分为我们输入的需要执行计划提示的命令和我们需要调试的SQL语句,红色部分为该语句在数据库中将使用的执行计划。
【免费下载】oracle11g SPA 应用在9i升级到10g SQL性能测试
SPA实施目的为了保证升级10g能更加平稳,我们采用Oracle 11g SQL 性能分析器(SQL Performance Analyzer,以下简称SPA)新功能来预测数据库的关键SQL在Oracle 10g平台上性能情况,以便提前发现问题并做相关的优化。
大型业务关键应用程序要在响应时间、吞吐量、运行时间和可用性方面提供特定服务级别的保证。
对系统的任何更改(如升级数据库或修改配置)通常都需要进行全面的测试和验证,然后才能在生产系统中实施这些更改。
在移到生产系统之前为了保证安全,数据库管理员(DBA) 必须让测试系统承受与生产环境中的工作量很近似的压力,以便分析系统级更改对整体SQL 性能的影响,并在在移到生产之前进行必要的优化。
Oracle Database 11g 引入了SQL 性能分析器;使用该工具可以准确地预测系统更改对SQL 语句性能的影响。
这种功能可向DBA 提供有关SQL 语句性能的详细信息,例如,执行前后的统计信息,提高或降低性能的语句。
这样,你就在测试环境中先进行更改,以确定数据库升级是否会影响SQL性能。
SQL 性能分析器可用于预测和防止会影响SQL 执行计划结构的任何数据库环境更改所带来的潜在性能问题。
这些更改可以包括(但不限于)以下任何一种更改:●数据库升级●实施优化建议●更改方案●收集统计信息●更改数据库参数●更改操作系统和硬件SQL 性能分析器是11g的新功能,通过相关的配置可以应用在Oracle 9i升级到10g的过程中,大致的框架如下:先收集9i数据库的上的sql trace信息(需要涵盖关键业务的SQL),然后在11g数据库上生成STS(SQL T uning Set)和SQL统计信息,接着把这些SQL通过数据库链连接到10g 数据库上运行并把统计信息返回到11g库上,最后对每条SQL生成9i和10g上的对比报告,从这个报告便能发现SQL性能是否改善,执行计划有没有改变。
ORACLE 9i 数据库入门 Oracle-2
数据利器 --- SQL
中文版基础教程.》 整书内容PDF文档 《Oracle.9i中文版基础教程 》随书光盘 整书内容 中文版基础教程 随书光盘--整书内容 文档 4.pdf
SQL概述 概述
1. SQL是什么? SQL是什么 是什么? 2. SQL的主要特点? SQL的主要特点 的主要特点? 3. Oracle 9i使用的SQL工具: SQLPlus Worksheet 9i使用的 使用的SQL工具 工具: select * from scott.emp 4. 显示数据表的结构命令( desc[ribe] 数据表名 ) 显示数据表的结构命令( desc[ribe] desc scott.emp
课后练习题(使用not in): 假如一个表 List 中的字段 K 为数值型。请写出SQL语句,查找不 连续的断点处的值。 譬如:K中的值为1, 2, 3, 8, 9, 25 时, 查询的结果应该为:1,8,25。 select k from list where k-1 not in (select k from list) 8
11
综合练习题
1、创建数据库 “myoracle” 。 、 ” 2、在上面创建好的库中,编写并执行创建以下三个数据表的 语句, 、在上面创建好的库中,编写并执行创建以下三个数据表的SQL语句, 语句 名称” 非空)。 表1: “课程编号表” 具有字段“编号”(主键)和“名称”(非空)。 : 课程编号表” 具有字段“编号” 主键) 学生信息表” 具有下列字段: 表2: “学生信息表” 具有下列字段: 编号(主键)、姓名、性别、出生日期、联系电话、通信地址。 )、姓名 编号(主键)、姓名、性别、出生日期、联系电话、通信地址。 表3: “学生成绩” 具有如下字段: : 学生成绩” 具有如下字段: 编号” 外键,参照“学生信息表”表的“编号” “编号”(外键,参照“学生信息表”表的“编号”), 课程编号” 外键,参照“课程编号表”表的“编号” “课程编号”(外键,参照“课程编号表”表的“编号”), 成绩” 核查约束其值在0至 之间 之间)。 “成绩”(核查约束其值在 至100之间)。 3、编写 语句向上面三个表中插入一些数据。 、编写SQL语句向上面三个表中插入一些数据。 语句向上面三个表中插入一些数据 4、针对上面三个表的数据,编写调试下列查询语句: 、针对上面三个表的数据,编写调试下列查询语句: 。(提示 (1)查询学生共参加了哪些课程的考试。(提示:“学生成绩”表中一共 )查询学生共参加了哪些课程的考试。(提示: 学生成绩” 有哪些不同的课程名称)。 有哪些不同的课程名称)。 字的所有学生的编号和姓名。 (2)查询姓名中含有“东”字的所有学生的编号和姓名。 )查询姓名中含有“ (3)查询某学生的考试科目和相应成绩。 )查询某学生的考试科目和相应成绩。 (4)查询某个课程的平均成绩。 )查询某个课程的平均成绩。
02_Oracle 9i 基本操作和简单SQL语句
19
2,ALTER TABLE 命令
修改现有列:
Alter table <table_name> modify (column definition …);
向现有表中添加新的列:
Alter table <table_name> add (column definition);
删除列
Alter table <table_name> drop column <column_name>; Alter table <table_name> set unused(tel_no);
利用现有的表创建表
语法:
CREATE TABLE <new_table_name> AS SELECT column_names FROM <old_table_name>;
SQL> CREATE TABLE newitemfile AS SELECT * FROM itemfile; SQL> CREATE TABLE newitemfile1 AS SELECT itemcode, itemdesc, qty_hand FROM itemfile; SQL> CREATE TABLE newitemfile2 AS SELECT * FROM itemfile WHERE 1 = 2;
LOB
CLOB
BLOB
BFILE
BFILE 即 Binary File(二进制文 BLOB 即 Binary LOB(二进制 CLOB 即 Character LOB(字符 件),它用于将二进制数据存储在 LOB),可以存储较大的二进制对 LOB),它能够存储大量字符数据 数据库外部的操作系统文件中 象,如图形,视频剪辑和声音文件
Sqltuning
8、使用DECODE函数来减少处理时间--2
你可以用DECODE函数高效地得到相同结果
SELECT COUNT(DECODE(DEPT_NO,0020,’X’,NULL)) D0020_COUNT, COUNT(DECODE(DEPT_NO,0030,’X’,NULL)) D0030_COUNT, SUM(DECODE(DEPT_NO,0020,SAL,NULL)) D0020_SAL, SUM(DECODE(DEPT_NO,0030,SAL,NULL)) D0030_SAL
Oracle Sql Tuning
Copyright © 2010, Oracle. All rights reserved.
Oracle 架构简介 Sql Tuning举例
纲要
1-2
Copyright © 2010, Oracle. All rights reserved.
纲要
1-3
Copyright © 2010, Oracle. All rights reserved.
1-13
Copyright © 2010, Oracle. All rights reserved.
7、减少访问数据库的次数
当执行每条SQL语句时, ORACLE在内部执行了许多工作: 解析SQL语句,估算索引的利用率,绑定变量, 读数据块等等. 由此可 见, 减少访问数据库的次数 , 就能实际上减少ORACLE的工作量. 例如: 以下有三种方法可以检索出雇员号等于0342或0291的职员.
1-7
Copyright © 2010, Oracle. All rights reserved.
4、选择最有效率的表名顺序
解析器按照从右到左的顺序处理FROM子句中的表名,
oracle9ir2 performance tuning guide and reference 学习笔记大白话_1_introduct_to_the_optimizer
1. Introduct to the Optimizer1.1 Overview of SQL Processing Architecture系统性能的低劣,很大程度都反映在SQL的response time上,而这主要与SQL处理过程中的db block gets/consistent gets/physical reads/sort(memory)/sort(disk)相关.而在优化这些之前,必须对Oracle整个的SQL处理架构有一定了解,而本段讲的就是这个.一张图(Figure1-1)就可完成表达本段内容.并且,Parser、Optimizer、Row Source Generator也共称为SQL Compiler. 偶们平常所说的shared cursor就是SQL被它处理后得到的.SQL Compiler也负责将shared cursor与execution plan联合.下面看一下组成SQL Compiler的各组件及作用: Parser这个不多说了,与其它语言一样,检查SQL词句的语法.因为SQL想处理的是Oracle数据库对象,而这些Oracle数据库对象名称的引用等也得由Parser来检验一下.Parsing完SQL了,当然就该走到下一步了(由Optimizer来生成execution plan).Row Source Generator接收到Optimum Method of Execution后,将由Row Source Generator来生成Execution Plan(这就是偶们通常所说的执行计划么?从字面上是可这么理解,但Oracle原文的定义偶也写出来).Execution Plan就是一树形结构的row sources的集合.每个row source对应的步骤都会返回一组行.(The execution plan is a collection of row sources structured in the form of a tree. Each row source returns a set of rows for that step.)SQL Execution EngineRow Source Generator将Execution Plan都生成了,那就由SQL Execution Engine来运行这个Execution Plan.运行各个row source 并生成SQL所需的结果.1.2 Overview of the OptimizerOptimizer大家都是如雷贯耳的,谁都知道会由它决定SQL执行的最佳路径.因为每个SQL都有很多种执行计划可选择,而且不同的执行计划的执行效率差别很大,所以才有最佳一说,也才需要Optimizer.需要说明的是,Oracle的Optimizer最早是用RBO方法,后来是RBO或CBO,现在是CBO或RBO,趋势是很明显的:). 这也意味着不同版本的Oracle Optimizer,处理同一SQL的行为有可能是不一样,且可能导致产生不一样的执行路径.作为一名DBA,你可以通过告诉(设置)Optimizer你所需的方法和目标,收集CBO相关的统计等途径来影响Optimizer的行为.而作为一名应用开发人员,若了解更多的Optimizer相关的信息,有利于编写出更高效的应用.另外,也可通过在SQL中加入hints的方式来直接告诉Optimizer你的SQL该如何执行.1.2.1 Steps in Optimizer Operations现在让偶们来看一个Optimizer处理SQL的典型流程,因为本段标题是Overview,因此偶也是直译,不会深究.Order Operation Description1. 评估表达式和条件Optimizer尽可能全面地优先评估包含常量(constrant)的表达式和条件.2. 语句转换主要是对于涉及(involving)子查询,视图之类的复杂SQL,Optimizer需将它转化为等价的join语句.3. 选择Optimizer approaches Optimizer选择CBO或RBO,并决定优化的目标.4. 选择Access Path 对于SQL需访问的每张表,Optimizer将选择一种或多种可行的Access Path来获取表中的数据.5. 选择Join Orders 若SQL中涉及两张(或以上)表的join,Optimizer就得决定哪两张表先join,然后是结果又与哪张表join,也就是多张表之间join的顺序.6. 选择Join Method对于5.中的每一步join,Optimizer会决定使用哪种Join Method最优.1.2.2 Understanding Execution Plans简而言之,一个SQL执行可分为好多步,每一步都可能从数据库物理存储中获取行数据或为获取数据作准备,而这些步骤的结合就被称Oracle对某个SQL的Execution Plan.Execution Plan含有1.2.1中由Optimizer选择的对每张表的Access Path,及所有表的Join Orders(Join Method).1.2.2.1 Overview of EXPLAIN PLAN就是偶们常用的explain plan工具.先建立plan_table,再执行explain plan …. ,Oracle会将SQL的Execution Plan存放在plan_table之中,你可以通过utlxpls或utlxplp查询并显示出来.请看例(Example 1-1).而下图(Figure 1-2)则更为直观地显示了Execution Plan的执行步骤:1.2.2.2 Steps in the Excution PlanExecution Plan的每一步都返回一个行集,这些行集或为下一步所用或因为已经是最终结果而被直接传给用户的应用.由每步返回的行集也称为Row Set.图(Figure1-2)以树形图显示了row sources在各步间传递的流程.Execution Plan的每个步骤或者从数据库中查询行数据或者从一(多)个row sources处接受行数据.以下是各步骤的详细解释:其中透明背景的box表示此步骤(1,2)处理之前步骤传回来的row sourceü第2步处理嵌套循环操作(nested loops operation),它接收来自于第3步和第4步的row sources,并且将第3步返回的行与相对应的第4步返回行作join,并将结果行数据传给第1步.ü第1步做过滤操作.它接受来自于第2步和第6步的数据,剔除存在于第6步返回的行数据中的第2步返回的行数据(not exists),并将剩余的第2步返回的数据传给执行SQL的用户或应用程序.1.2.2.3 Understanding Execution OrderExecution Plan的真实执行步骤并不是按照所标数字来顺序执行的.而是先执行在图Figure(1-2)中所示的树形结构的叶节点所在步骤(第3,5,6步).因为他们都不需要等待别的步骤的执行结果就可执行(树形结构中叶节点,只有父节点,而无子节点).这些叶节点所返回的行数据被交给其在树形结构中的父节点作处理.对应到EXPLAIN PLAN所产生并显示出来的Execution Plan,是缩进到最右边的步骤先执行,执行结束后执行父步骤.若缩进一致,则最上面的步骤先执行.(因担心译得有问题,兹将原文贴上) (Note: The execution order in EXPLAIN PLAN begins with the line that is the furthest indented to the right. The next step is the parent of that line. If two lines are indented equally, then the top line is executed first.) 对于例(Example 1-1)来说,就如图(Figure 1-2)所示,其执行如下:Oracle先执行第3步将将结果行数据一个接一个地返回给第2步1.3 Choosing an Optimizer Approach and Goal(这里的approach是指CBO或RBO,而Goal就是指CBO的first rows/first rows n/all rows)1.3.1 Optimizing Goal of Vary ApplicationCBO的缺省目标是最佳的吞吐量.这种情况下,CBO规则倾向于使用最少的必要资源来处理SQL语句访问到的所有行.Oracle也可以将SQL语句的目标设置为最佳的response time.这种情况下,CBO规则倾向于使用最少的必要资源来处理SQL语句访问到的第一行(最快速返回第一行结果).Optimizer所产生的Execution Plan是依赖于Optimizer的目标而变化的.例如,为了最佳throughout,则Optimizer更倾向于使用全表扫描而不是使用索引扫描;或者倾向于使用sort merge join而不是nested loop join(嵌套循环联接).但在目标为最快响应时间时,则优化器更倾向于使用index scan或nested loop join.例如: 假设你有一个join语句,这个语句既可以sort-merge join运行也可以nested loops join运行.则sort-merge join则倾向于更快速地返回整个结果集(OLAP/DSS),而使用nested loops join则可更快速地返回结果集的第一行(OLTP).若偶们的目标是提高吞吐,则Optimizer倾向于选择一个sort-merge join.若你的目的是提高response time,则Optimizer倾向于选择一个nested loop join.因此,从这个角度上来讲,应该是基于应用的需求来为Optimizer选择目标的:对于批处理的应用,如Oracle Reports 应用,优化目标应该是最佳的吞吐.通常,吞吐在批处理应用之中更为重要,因为用户在运行应用后,只关注于完成应用所需的时间.相对而言,response time就不太重要,因为用户不会在应用运行时检查每个独立语句的结果.用alter session命令所设置的OPTIMIZER_GOAL会话级参数在数据字典中的CBO统计time)返回结果的前N(N可以为1,10,100,1000)行.FIRST_ROWS Optimizer将综合使用成本和启发(heuristics)来找出最快返回结果第一行的执行计划.注意: 在使用启发(heuristics)时,有可能会导致CBO生成成本比不使用启发(heuristics)高得多的执行计划.FIRST_ROWS这个参数主要是为了用于向后兼容和保持原计划的稳定性的.RULE Optimizer将使用RBO而不管统计信息是否存在.例如: 以下的命令设置当前会话的优化器使用CBO,优化目标为最快时间返回结果集的前10行:ALTER SESSION SET OPTIMIZER_MODE = FIRST_ROWS_10;若Optimizer使用CBO,并且SQL所访问的某些表没有统计,则Optimizer将使用一些interanl的信息(例如这个表allocated了多少数据块)来估计这些表的其它统计数据.1.3.2.2 OPTIMIZER_GOAL Parameter of the ALTER SESSION Statement在当前会话中用ALTER SESSION命令设置的OPTIMIZER_GOAL会override初始参数OPTIMIZER_MODE的设置.OPTIMIZER_GOAL参数将影响在当前会话中执行的SQL(包含调用的Procedure和Function),但不会影响因用户SQL而引起的Oracle内部递归(recursive)SQL语句(如:空间管理或数据字典管理)的优化.OPTIMIZER_GOAL可设置的参数列表与OPTIMIZER_MODE的参数列表完全一致,其意思也完全一致(只不过是为了区分SESSION和全局,而特意使用不同的参数名称).1.3.2.3 Optimizer SQL Hints可以在SQL中添加优化相关的Hints,并override全局OPTIMIZER_MODE初始参数和当前会话的OPTIMIZER_GOAL参数.可在SQL中添加的Hints如下:FIRST_ROWS(n) FIRST_ROWS ALL_ROWS CHOOSE RULE缺省情况下,CBO的优化目标是最佳吞吐.你可通过以下途径来更该CBO的优化目标:自Oracle8i开始,用DBMS_STAT包(Oracle不建议使用ANALYZE命令).对于Oracle8i之前的版本,使用ANALYZE命令.对于表中某些列中的值域分布不均衡的情况(偶的理解是: 以这些列分组并统计记录总数时,分组记录数存在数量级差别,也就是不均衡),你还得收集柱状图.上句的原文如下: For table columns that contains skewed data(in other words, values with large variation in number of duplications), you should collect histograms.统计结果将向CBO提供数据唯一性和分布的信息. CBO可以用这些信息来精确计算各种计划的成本.既然已知道不同计划的不同成本,则CBO当然会选择成本最低的计划来执行.注意:Oracle公司推荐用户使用DBMS_STATS包替代ANALYZE命令来收集统计信息.因为这个包可以并行地收集统计,对分区对象收集全局的统计,还提供精细地调整你的统计的功能.将来CBO将只使用由DBMS_STAT包收集的统计.那么ANALYZE命令在将来(现在)还有什么用呢? 主要是收集一些与CBO不相关的统计,例如:使用VALIDATE来校验对象结构有效性Index-organized tables(IOT)Reverse key indexesParallel query and parallel DMLStar transformations and star joinsEnterprise Manager progress meter Hash joins1.4 Understanding the CBOOracle公司一直在增强CBO,而某些Oracle新版本的特性也需要用到CBO.至于RBO,Oracle只是为了向后兼容而保留.因此,应该使用CBO.CBO在生成SQL的计划时,会考虑对象的可访问路径和对象的统计信息,才会决定哪个执行计划是最优的.CBO还会考虑hints(用户置于语句中的优化建议).以下是CBO执行的步骤:A. 基于可用的访问路径和hints, Optimizer为SQL语句生成一个有效的计划集合.B. Optimizer基于SQL语句所访问对象存在数据字典中的统计(即对象的数据分布和存储特性),来评估每个计划的成本.所谓成本(Cost)就是执行(某个SQL的)某种计划估计需要使用到多少资源.Optimizer评估执行所需用到的计算机资源(包括I/O,CPU和内存),根据结果来计算access paths和join orders的成本.成本高的计划比成本低的执行计划需要更长的执行时间.但在使用一个并行计划时,资源的使用并不能直接反映到执行所需要的时间上去.1.4.1 Architecture of the CBOCBO包含三个主要组件: Query Transformer / Estimator / Plan Generator其结构如图(Figure 1-3)所示.1.4.1.1 Query TransformerQuery Transformer的输入数据是一个已parse好的查询,这个已parse好的查询中含有多个查询块(需查询的子句).这些查询块相互嵌套或相关联.Query Transformer的主要目标(objective)是通过改变查询语句的格式来降低执行成本,以生成更优化的查询计划.Query Transformer共提供四种不同的查询转换技术:View Merging /Predicate Pushing/Subquery Unnesting/Query Rewrite with Materialized Views 下面将逐一介绍这四种Query Transformer技术.View Merging查询SQL中引用到的每个视图都被parser展开为独立的query block. 这些query block本质上是对应着view 的定义,因此也会产生一个view. 对于Optimizer来说,最简单的办法是,独立地分析view所对应的query block,并且独立生成一个view子计划(subplan). Optimizer然后在整个执行计划中使用view的subplan,并生成最终计划.这种技术常会导致次优(非最优)计划,因为视图是独立于查询其它部分作优化的.Query Transformer将移走次优计划,并将视图对应的query block合并到整个SQL中去.绝大多数视图都会被合并.当视图被合并时,对应于视图的query block被合并到整个查询SQL中去.这时也就不必单独生成视图相关的subplan了,因为视图对应的query block已删除了.1.0表时整个row set中的行全都被选出.假如统计全是不可用的,则Estimator会使用一个内部的缺省Selectivity值. 而这个缺省值还取决于查询条件的写法.例如,等于条件late_name=’Smith’使用的内部缺省值就比大于条件last_name>’Smith’使用的内部缺省值来得小(这是可以理解的).因为Estimator知道用等于条件式所获得的结果通常小于用范围条件式所获得的结果.当统计可用时,Estimator使用统计来评估Selectivity. 例如,对于一个等于查询条件(last_name =’Smith’),selectivity is set to the reciprocal of the number n of distinct values of last_name,because the query selects rows that all contain one out of n distinct values. If a histogram is available on the last_name column, then the estimator uses it instead of the number of distinct values. The histogram captures the distribution of different values in a column, so it yields better selectivity estimates. Having histograms on columns that contain skewed data(in other words, values with large variatations in in number of duplicates) greatly helps the CBO generate good selectivity estimates.CardinalityCardinality对应于row set中总行数.在这里,row set可能对应于一个表,或者join的结果,或者GROUP BY 操作出来的结果.Base Cardinality 表示base表的记录行数.Base Cardinality可以通过分析表计算出来.如果表上的统计不可用,则Estimator将会使用表当前的extents数来评估表的Base Cardinality.Effective Cardinality表示从基表中选出的记录行数.Effective Cardinality取决于查询基表时使用的各列的条件.Effective Cardinality是基于Base Cardinlality和相关的查询条件计算出来的.当没有任何查询条件时,则Effective Cardinality就等于Base Cardinality.Join Cardinality表示两个row sets关联后产生的结果记录行数.Join是两个行集作笛卡尔运算,并用join条件来过滤并获得想要的结果. Therefore,the join cardinality is the product of the cardinalities of two row sets,multiplied by the selectivity of the join predicate.Distinct Cardinality 是row set的某列中distinct值的数量.Group Cardinality是在对某row set作GROUP BY操作后,产生的记录行数.GROUP BY操作将会减少row set 的行数.Group Cardinality取决于row set的总行数和分组条件列中的distinct值的数量.例子(Example 1-2)显示了一个GROUP BY语句.假设基于colx分组的总共为100行,而其上的Distinct Cardinality为30,则Group Cardinality为30.而若是多个列同时分组,则可用以下公式来算出Group Cardinality:Cost成本表示使用到的工作单元或资源.CBO使用磁盘I/O,CPU使用量和内存使用量作为工作单元.因此,CBO使用的成本表示评估出的运行期间要用的到磁盘I/O数和CPU总数和需用到的内存数.操作可以是扫描一张表,使用索引访问表中的行,将两个表join在一起,或者对一个row set作排序操作.üAccess Path则表示从一张表中取出数据需要多少单员的工作量.Access Path 可以是a table scan,a fast full index scan,an index scan.在table scan或fast full index scan时,在一个I/O操作中会读出多个块.因此,table scan和fast full index scan的成本取决于扫描的总块数和每次I/O读出多少块. 而index scan的成本则取决于B-tree的级数,要扫描的索引叶节点块数,和使用中索引中的ROWID来查询的记录行数. The cost of fetching rows using rowids depends on the index clustering factor.虽然聚集系数(clustering factor)是索引的一个属性,聚集系数实际上也与表的数据块中索引列值分布相关. 低聚集系数表明各数据行是集中于表的少部分块中.反之,高聚集系数表明各数据行是分散于表的很多块中(需要更多随机访问).所以,高聚集系数意味着在使用rowid作范围扫描时,需要更多的成本才能获得数据,因为需访问更多数据块.例子(Example 1-3)显示了聚集系数如何影响成本.这个例子的主要意(但现实的情况是,某些表通常有多种cluster需求,以满足多种查询需求,所以这就很难平衡了).üJoin Cost represents the combination of the individual access costs of the two row set being joined.在一个join中,通常称其中一个row set为inner,而另一个row set为outer.A.Nested loop join,对于outer row set中的每一行,都从inner row set并找出匹配的行进行join.因此,在nested loop join时,inner row set被访问的次数等于outer row set的行数.Cost= outer access cost + (inner access cost * outer cardinality)B.Sort merge Join,如果需要join的两个row set未按join key排序,则先将它们按join key排序.Cost = outer access cost+inner access cost +sort costs(if sort is used)C.Hash Join,对innter row set作hash运算,并将hash结果放入内存, 并对join key生成一张hash table. 再对outer row set的每行作hash运算,也生成join key的hash table,并与inner row set的hash table作匹配. 如果inner row set 很大,则只有部分被hash到内存中,这部分被称为hash partition.Outer row set的每一行都会作hash运算,并与相应的hash partition中的行作匹配. 在完成一个hashpartition的匹配后,再对另一hash partition作匹配,直到完成所有hash partitoin的匹配.Cost = (outer access cost * #of hash partitions) + inner access cost1.4.1.3 Plan GeneratorPlan Generator的主要功能就是根据查询生成多种可行的不同计划,并找出其中成本最低的计划(这些不同的计划都可以执行出相同结果,只不过所需成本不一样). Many different plans are possible because of the various of combinations of different access paths,join methods, and join orders that can be used to access and process data in different ways and produce the same result.连接顺序(join order)指需连接的多个对象(比如表)可以按不同顺序访问并连接在一起.Plan Generator首先生成每个nested子查询和未合并视图的计划.每个nested子查询或未合并视图都对应一个独立的子查询块.这些查询块的优化是自底向上的.即最里面的查询块先优化,并生成一相应的子计划.而最外的查询块对应于整个查询,将会是最后被优化的.Plan Generator尝试不同的access paths,join methods,join orders来生成不同的计划.能生成多少可用计划与SQL查询的FROM子句后需要join的表或视图数量成指数比率.在查找最低成本计划的过程中,Plan Generator使用内部的cutoff机制来减少需要尝试的计划数量.而cutoff是基于当前的最优计划.若当前最低成本很高,则Plan Generator会更努力(尝试更多计划)地去寻找更低的成本计划.若当前的成本是最低的,则Plan Generator会迅速地结束搜索,因为将来(查找到)的计划很难(比现有最佳计划)显著地改进.Plan Generator以成本较低的计划开始做cutoff,则Plan Generator会工作得很好(这个很好理解).找出一个良好的初始join order是很困难的.而Plan Generator使用了简单启发式的办法来找出初始join order. Plan Generator会将所有需要join 的item按其effective cardinalities(就是从基表中查询出的记录数)从小到大排序,并按此顺序来join.1.5 Understanding Access Paths for the CBOAccess Paths就是指用何方法从数据库中检索出数据.不管哪张表中的哪一行数据都可以按以下方法定位并检索出来:Rowid: 用rowid去检索行是速度最快的方法,因为rowid可以精确地指定行在数据库中的物理位置.通常,用索引访问数据的方法较适合用于从表中查出相对较小的结果集,若需从表中查出大多数记录,则用full table scan会更高效.OLTP的SQL一般都有很高的selectivity,并且运行时间很短,因此它们通常使用index access path.另一方面,DSS系统常需用到表中大部分数据,因此常用full table scan access path.这一段将着重说明以下几种access path:Full table scans / Sample table scans / rowid scans/ index scans / cluster scans/ hash scans1.5.1 Full Table Scans在全表扫描过程中,Oracle会扫描所有在HWM之下的数据块,并将行数据与WHERE子句作匹配.当Oracle执行全表扫描时,是按顺序读数据块的.因为数据块是相邻近的,所以在一次I/O中读取更多的数据块可以提高性能.初始参数DB_FILE_MULTIBLOCK_READ_COUNT就可设置一次I/O读多少块.在例子(Example 1-4)中,假设你想在employees表中查找一个人的名字(且大小写敏感)虽然在employees表中可能有成千上万的记录,但满足查询条件的employee可能只有20条.这更应使用索引来访问所需的行(若在employees表的last_name列上有索引的话).然而,Optimizer不能使用这个索引,因为在索引列上有一个函数. 因没有(更好的)access path,Optimizer只能使用full table scan. 如果你想在大小写敏感的查询中使用索引,要不就别在查询列中混合存放大小写的值,或者别在查询列上建立基于函数的索引.When the Optimizer Uses Full Table ScansOptimizer在下列情况时使用full table scan:üLack of Access Paths若查询不能使用到任何现有索引,则只能使用full table scanüLarge Amount of Data如果Optimizer认为到查询会访问到表中多数块,则它会使用full table scan(即使在索引可用的情况下) üSmall Table如果表中HWM下的块总数小于DB_FILE_MULTIBLOCK_READ_COUNT,则整个表可以在一次I/O中全部读出,则使用full table scan比使用index range scan成本更低,而不管表的碎片(fraction)程度或是否存在索引.üOld Statistics如果表自建立以来都没有分析过,且表中HWM下的块总数小于DB_FILE_MULTIBLOCK_READ_COUNT,则Optimizer认为表很小并应该使用full table scan.可以查找ALL_TABLES数据字典中的LAST_ANALYZED和BLOCKS两个列来看统计的状态.üHigh Degree of Parallelism将表的并行度设得很高会使Optimizer倾向于使用full table scans而不是range scans. 你可在ALL_TABLES 数据字典中的DEGREE列来查看表的并行度.Why a FULL Table Scan Is Faster For Accessing Large Amounts of Data当需要访问表中的多数记录时,使用full table scans将比使用index range scans成本更低.因为full table scans可以用大I/O调用,而用少量的大I/O调用会比用大量小的I/O调用成本更低.一次I/O调用需多少时间由两部分组成:üCall setup time(head seek time,rotational latency)üData transfer time(typically 10 MB a second or better)在标准的I/O操作中,setup占用了大多数时间. 传送一个8k大小的buffter时间小于1 msec(out of the total time of 10 msec).这就意味着,你可以在每次128KB单独的I/O调用中,可在约20 msec内传送128KB的数据,而128KB 的数据需要16次每次8KB的调用,并将耗时约160msec.例子(Example1-7)说明了这种情况.当CPU数据量增长时,使用index range scan所需时间,又会降低.但对于需要查询出表中大多数记录的查询,full table scan还是速度较快.例子(Example1-9)显示了先作index range scan,然后根据得到的rowid去查找行数据.Unique(B-tree)索引的每列都在SQL语句中以等于条件出现时,Optimizer将使用unique index scan.在例子(Example1-11)显示了一些未使用unique index scans的情况(未使用全部unique 索引的列或未全使用等于条件).的列,例如create index idx_test on test(id,name,age); 其中id就可称为idx_test索引的引导列,而id,name联合起来也可称为idx_test索引的引导列),有以下表达式时,将使用index range scan:üCol1 = :b1üCol1 < :b1üCol1 > :b1ü以上条件需用AND与之前的条件相连ü而出现col1 like ‘%ASD’这种LIKE条件表达式,Optimizer将不能使用index range scan.Range scans可以使用unique或nounique索引. 当索引列包含在ORDER BY/GROUP BY子句时,可以避免Range scan排序.1.5.4.3 Index Range Scans DescendingIndex range scan descending与index range scan是相同的,只不过返回的数据是按降序排列的.(缺省情况,索引是按升序排列的.) 通常,index range scan descending用于查询并先返回最近的数据或者查找小于某个值的数据.例子(Example1-17)使用了由order_id和order_mode组成的复合索引.所检查行的order_id,order_mode,rowid是以降序存放的.不过,因为对每个order_id和order_mode只有一行与之相对应(orders_u2是基于这两列的unique索引),也可以说这些行是按order_id,order_mode排序的.例子(Example1-18)使用了单列<purchase_order_num>上的索引画查询.而检索到的数据是按<purchase_order_num>和rowid降序排列的.Index Range Scan Descending Hints在SQL中使用以下hint可以使用index range scan descending: INDEX_DESC(table_alias index_name),例子(Example1-19)演示了此用法.1.5.4.4 Index Skip ScansIndex skip scan可提高非前缀列的查询的索引扫描性能.通常,扫描索引块比扫描表的数据块速度更高.Skip scan可将复合索引从逻辑上分割为多个小的子索引.在skip scan时,组成复合索引的第一列并未在SQL语句中作为条件使用.这也就是为什么称为”skipped”.有多少个逻辑的子索引完全取决于复合索引第一列有多少重复列值(这个也很易理解).若复合索引的第一列只有很少重复值则只有很少的逻辑子索引,这样index skip scan就很有效,反之则效率较低(值少了,则与local partition index可比).例子(Example1-20),演示了index skip scan的作用.1.5.4.5 (Index) Full Scans如果在WHERE子句中引用到了某个组成索引的列,则full scan就是可用的.The predicate does not need to be an index driver. 即使没有WHERE子句,如果满足以下两个条件,也将使(index) full scan可用:只有在用CBO时才能用index fast full scan.你可以通过设置初始参数OPTIMIZER_FEATURES_ENABLE或INDEX_FFS hint来允许CBO使用index fast full scan. 另外,index fast full scans不能用在bitmap的索引上.Index fast full scan比普通的index full scan更快,因为这种模式可象table scan一样用multiblock I/O和并行特性.例子(Example1-21)显示了这种特性.因为在索引t2_c1_idx中含有t2表中的所有列,因此Optimizer将在此索引上作index fast full scan.Index Fast Full Scan Restrictionsü在索引所含列中到少有一个有NOT NULL的约束ü如要作并行搜索,一定需在索引上设置了并行度.(索引的并行度与表的并行度是相互独立的,需要单独设置.因为它们是不同的segment).ü必须先对索引作分析,否则,Optimizer或许会不用index fast full scan这种访问模式.Index Join Hints可通过设置初始参数OPTIMIZER_FEATURE_ENABLE或在SQL中加入INDEX_JOIN hint来允许和提示Optimizer 使用index join这种访问模式.1.5.4.8 Bitmap JoinsBitmap join用映射函数将bitmap索引键值位图中的每个位映射到一个rowid. Bitmaps can efficiently merge indexes that correspond to serveral conditions in a WHERE clause, using Boolean operations to resolve AND and OR conditions(Bitmaps用布尔操作来高效地合并使用WHERE子句中AND和OR条件所用到的索引).Bitmap这种访问模式只能用于CBO.Note: 只在Oracle9i的Enterprise Edition这个版本才可用bitmap indexes和bitmap join特性,在Standard Edition中是无此功能的.1.5.5 Cluster Scans如果表存放在indexed cluster中,则可用cluster scans检索出所有相同cluster key值的行. 在indexed cluster中,相同cluster key值的行,都存放在同一个数据块中. 执行cluster scan前,Oracle需先获得某行的rowid,以用于搜索cluster索引. Oracle可以根据这个rowid找到对应的行.1.5.6 Hash ScansHash scan根据一个hash值查找存放于hash cluster中的行.在hash cluster中,有着相同hash值的行都存放在同一数据块中.执行hash scan前,Oracle需先对SQL语句中指定的cluster key值作hash函数并得到一个hash值,然后根据此hash 值到数据块中搜索对应的数据行.1.5.7 How the CBO Chooses an Access PathCBO基于以下因素来选择什么访问路径:。
构建环境安装Oracle
第2章构建环境——安装Oracle 9i本章介绍Oracle 9i网络中两种主要的成分——数据库服务器和管理客户机的安装和配置过程。
本章目的在于帮助读者掌握如何安装Oracle 9i以及如何配置Oracle 9i网络环境。
2.1 安装数据库服务器本书采用Windows 2000 Server作为安装的网络操作系统平台,数据库服务器采用Oracle 9i Database for Windows 2000的企业版。
2.1.1 安装的硬件环境需求下列从5个主要的方面阐述Oracle 9i对硬件环境的要求。
1. 对CPU的要求CPU最低配置到Pentium 166就可以。
2. 对内存的要求内存容量最低为64MB,最好在256MB以上。
3. 对硬盘的要求建议配置8GB容量以上硬盘。
4. 对光驱的要求建议选用快速光驱,16倍速以上。
5. 对网卡的要求一般可以选用10/100MB自适应网卡。
2.1.2 安装的软件环境需求下列从两个主要的方面阐述Oracle 9i对软件环境的要求。
1. 对操作系统的要求建议在全新安装的Windows 2000 Server上安装数据库服务器,在Windows 2000 Server 或Windows 98上安装管理客户机。
2. 对虚拟内存的要求建议可以将虚拟内存适当进行调整以加快安装速度。
2.1.3 安装的网络环境需求安装Oracle 9i数据库服务器,至少需要有两台计算机,通过交换机或集线器构成局域网。
2.1.4 安装环境实例安装环境实例如图2.1所示。
集线器管理客户机数据库服务器Windows 98Windows 2000 Server图2.1 安装环境实例1. 数据库服务器2. 管理客户机表2.1 安装环境里计算机的配置情况 配置项 服务器客户机CPU Pentium II 400赛扬466内存320MB 64MB 硬盘10GB 8GB光驱 16倍速CD-ROM 16倍速CD-ROM网卡 Intel Pro +10/100Mbit/s 自适应网卡 Intel Pro +10/100Mbit/s 自适应网卡2.1.5 用【Ping 】命令测试网络是否连通(1)输入“ping 192.168.100.5 -t ”命令行,单击按钮。
OracleSQLtuning数据库优化步骤分享(图文教程)
OracleSQLtuning数据库优化步骤分享(图⽂教程)SQL Turning 是Quest公司出品的Quest Central软件中的⼀个⼯具。
Quest Central是⼀款集成化、图形化、跨平台的数据库管理解决⽅案,可以同时管理 Oracle、DB2 和 SQL server 数据库。
SQL语句的优化对发挥数据库的最佳性能⾮常关键。
然⽽不幸的是,应⽤优化通常由于时间和资源的因素⽽被忽略。
SQL Tuning (SQL优化)模块可以对⽐和评测特定应⽤中SQL语句的运⾏性能,提出智能化的优化建议,帮助⽤户改善应⽤的响应时间。
SQL优化模块具有⾮介⼊式SQL采集、⾃动优化和专家建议等功能,全⾯改善SQL优化⼯作。
1、打开Quest Database Management Solutions弹出窗⼝如图1所⽰图12、在红⾊标记处打开SQL Tuning 优化SQL(1)建⽴连接。
在Quest Central主界⾯上的“Database”树上选择“SQL Server”,然后在下⽅出现的“Tools”框中选择“SQL Tuning”选项,打开“Lanch SQL Tuning for SQL Server Connections”对话框(图2、图3)。
我们在这⾥建⽴数据库服务器的连接,以后的分析⼯作都会在它上⾯完成。
图2 “建⽴连接”对话框图3双击“New Connection”图标,在弹出窗⼝中输⼊数据库的信息,单击“OK”,然后单击“Connect”即可。
(2)分析原始SQL语句,在单击“Connect”后将弹出⼀个新窗⼝,如图4图4在打开窗⼝的“Oriangal SQL”⽂本框内输⼊需要分析的原始SQL语句,红⾊标记处选择对应的数据库名,SQL语句代码如下:图5 分析原始SQL语句原始SQL语句然后点击⼯具栏上的“Execute”按钮,执⾏原始的SQL语句,SQL Tuning会⾃动分析SQL的执⾏计划,并把分析结果显⽰到界⾯上(图5)。
ora9i精简版安装步骤和常见问题
如果连接不成功,用前面的部分检查网络服务名部分部分是否正确,如果确信网络服务名部分正确而且所有的客户端都连不上数据库则可能为系统TCP/IP或Oracle系统有问题,建议重新安装数据库。
常见故障解决办法:
TNS-12154 (ORA-12154):TNS:could not resolve service name
test =
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)(HOST=testserver)(PORT=1521))
)
(CONNECT_DATA=(SERVICE_NAME=)
)
)
)
(CONNECT_DATA=(SERVICE_NAME=)
)
)
sql*plus运行基本机理:
在用户输入sqlplus system/manager@test后,sqlplus程序会自动到sqlnet.ora文件中找NAMES.DEFAULT_DOMAIN参数,假如该参数存在,则将该参数中的值取出,加到网络服务名的后面,即此例中你的输入由sqlplus system/manager@test自动变为sqlplus system/manager@ ,然后再到tnsnames.ora文件中找网络服务名,这当然找不到了,因为该文件中只有test网络服务名,所以报错。解决的办法就是将sqlnet.ora文件中的NAMES.DEFAULT_DOMAIN参数注释掉即可,如#NAMES.DEFAULT_DOMAIN = 。假如NAMES.DEFAULT_DOMAIN参数不存在,则sqlplus程序会直接到tnsnames.ora文件中找test网络服务名,然后取出其中的host,port,tcp,service_name,利用这些信息将连接请求发送到正确的数据库服务器上。
Oracle Server X9-2 和 Oracle Server X9-2L 产品说明说明书
Frequently Asked QuestionsOracle Server X9-2 andOracle Server X9-2L Oracle Server X9-2 and Oracle Server X9-2L are two-socket X86 servers designed for maximum security, reliability, and performancefor Oracle Database. The servers are powered by Platinum, Gold orSilver Third Generation Intel® Xeon® Scalable Processors and 32 memory slots. Oracle Server X9-2 is an ideal building block forrunning Oracle software in the cloud. While Oracle Server X9-2L server is designed for databases, enterprise storage, and big datasolutions.Oracle Server X9-2Oracle Server X9-2LCustomer Benefits Oracle Server X9-2 is designed to be the most secure database serverfor clustered databases and virtualized environments. It has been optimized for relational database with existing SAN/NAS. The serveraccelerates Oracle RAC with hot-swappable flash using Oracle’s unique NVMe design. Maximizes I/O bandwidth for virtual machine(VM) consolidation of enterprise applications. Oracle X9-2 has beendesigned from the ground up to be the most secure and reliable 1Userver.Oracle Server X9-2L is designed for maximum storage IOPs.Optimized for maximum storage capacity with up to 216 TB conventional storage or 132.8 TB high bandwidth flash. It reducesOpEX with in-depth management engineered into Oracle ILOM. It also maximizes I/O bandwidth and expandability offering flexibility tothe customer.Frequently Asked QuestionsQ: Where can I find the Oracle Server X9-2 and X9-2L data sheets?A: Oracle x86 Servers- DatasheetsQ: How does Oracle Server X9 generation compare with Oracle Server X8 generation?A:Oracle Server X9 is based on the Platinum, Gold and Silver Third Generation Intel®Xeon® Scalable Processors Ice Lake SP, while Oracle Server X8 was based on thesecond-generation Intel® Xeon® Scalable Processors.Q:What kind of applications and workloads are Oracle Server X9-2 and Oracle Server X9-2L best suited to run?A:Oracle’s X86 systems are the best X86 platforms to run Oracle software. With anoptimal balance of compute power, memory capacity, and I/O capability in a compactand energy-efficient 1U enclosure, the versatility of Oracle Server X9-2 makes it ideal forthe following:• A building block for private cloud infrastructure•Oracle Database clusters including Real Application Clusters (Oracle RAC)deployments•Enterprise-class applications in virtualized environments•Environments requiring highly secure and reliableX86-based infrastructureA:With superior scalability in compute performance, memory capacity, I/O bandwidth, andexpandability, as well as flexibility in storage configurations, Oracle Server X9-2L is idealfor the following:•Single-node Oracle Database environments•Storage server for big data and cloud storage solutionsQ:Does Oracle Server X9-2 and Oracle Server X9-2L take advantage of processor stock-keeping units (SKUs) capable of three Intel® Ultra Path Interconnect (UPI) links?A:Yes. The motherboard design of Oracle Server X9-2 and Oracle Server X9-2L connectsthree UPI links between the two processors, maximizing the bandwidth of interprocessorcommunication.Q:What is included in the Oracle Server X9 base chassis?A:The Oracle Server X9-2 1U base chassis includes the motherboard, three 16 lane low-profile PCIe 4.0 slots, 1000BASE-T Ethernet network and host management ports, oneserial RJ-45 management port, Oracle Integrated Lights Out Manager (Oracle ILOM)service processor, Trusted Platform Module (TPM) version 2.0, one rear USB 3.0 port,two 1,200-watt platinum-rated power supplies with up to 91 percent efficiency, one tool-less rack mounting slide rail kit, and one cable management arm.A:The Oracle Server X9-2L base chassis includes the motherboard, 10 low-profile PCIe 4.0slots (two with 16 lanes and eight with 8 lanes), 1000BASE-T Ethernet network and hostmanagement ports, one serial RJ-45 management port, Oracle Integrated Lights OutManager (Oracle ILOM) service processor, Trusted Platform Module (TPM) version 2.0,one rear USB 3.0 port, two 1,200-watt platinum rated power supplies with up to 91percent efficiency, one tool-less slide rail kit, and one cable management arm.Q:What flash storage options are available on Oracle Server X9?A:Oracle Server X9-2 supports up to four 6.8 TB or 3.84 TB high-bandwidth NVMe SSDs, for a total capacity of up to 27.2 TB. Oracle Server X9-2 also supports two 240 GB M.2 Serial ATA (SATA) SSDs.A:Oracle Server X9-2L supports up to twelve 6.8 TB or 3.84 TB high-bandwidth NVMe drives, plus an additional eight Oracle Flash Accelerator F640 PCIe Card v3 for a total capacity of 132.8 TB. Oracle Server X9-2L also supports up to two 240 GB M.2 SATA SSDs.Q:What memory and I/O expansion features are supported on Oracle Server X9?A:Oracle Server X9-2 includes 32 DDR4 DIMM slots, and it can be configured with 32 GB RDIMMs dual rank, or 64 GB RDIMMs dual rank.Oracle Server X9-2 has an optional 100 Gb/sec Ethernet adapter (mezzanine) card on MB with two QSFP ports, andthree 16 lane low-profile PCIe 4.0 expansion slots For more information on supported PCIe cards, visit the Oracle Server X9-2 option card support page.A:Oracle Server X9-2L includes 32 DDR4 DIMM slots, and it can be configured with 32 GB RDIMMs dual rank, or 64 GB LRDIMMs dual rank. There are 10 low-profile PCIe 4.0 expansion slots are available for configuring a number of Ethernet and Fiber Channel option cards. For more information on supported PCIe cards, visit the Oracle Server X9-2L option card support page.Q:Does the memory for Oracle Server X9 support error-correcting code (ECC)?A:Yes.Q:What operating systems are certified to run on Oracle Server X9?A:Oracle Server X9-2 and Oracle Server X9-2L are certified to run Oracle Linux, Oracle Solaris, and Oracle KVM.To see a list of supported operating system versions, visit the Oracle Server X9-2 and X9-2L operating system support page.Q:What system management options are available for Oracle Server X9 systems?A:Oracle Server X9 systems include an embedded service processor: Oracle ILOM.Oracle ILOM helps to simplify data center management, system configuration, and server lifecycle management by providing a rich set of management interfaces for monitoring the health of the system and for remote server management.Oracle Hardware Management Pack is a set of command-line tools and agents that assists with automating server configuration through tools running on the host operating system.These tools provide a means for scripting RAID, BIOS, and Oracle ILOM configuration as well as for updating all embedded firmware.In addition, Oracle Hardware Management Pack provides agents that monitor the health of the storage subsystem and provide remote SNMP monitoring.Q:Can the server configuration options be customized?A:Oracle Server X9 can be customized to the configuration you specify through the Oracle’s factory assemble-to-order (ATO) process.Q:What high-availability features are available in Oracle Server X9-2 and Oracle Server X9-2L?A:Oracle Server X9 systems offer hot-swappable and redundant cooling fans, and power supply units. Combining these enterprise-class reliability, availability, and serviceability (RAS) capabilities with the fault isolation and management features of Oracle ILOM, Oracle Solaris, or Oracle Linux enables Oracle Server X9 systems to maximize uptime, simplify system management, and reduce operational expenses.Q:What are the power requirements for Oracle Server X9-2 and Oracle Server X9-2L?A:The online power calculators provide an estimate of the idle and operating power level of the server.Q:What automated service request support is provided for Oracle Premier Support customers?A:Oracle Auto Service Request, one of the features available in all of Oracle’s X86 servers, detects and reports potential issues to the Oracle support center without user intervention, ensuring maximum service levels and simplifying support.Q:Can I mix and match SAS and NVMe drives in the same server?A:No. Oracle Server X9-2 only support NVMe drives in its four drive bays.A:No. The drives in the twelve drive bays in Oracle Server X9-2L must be populated as all NVMe or all SAS.Q:What is included with Oracle Premier Support?A: For more information, please see Oracle Premier Support for Systems.Q:What is the difference between Oracle Server X9 and Oracle Server X9 TAA?A: Oracle Server X9-2 TAA (7602915) and Oracle Server X9-2L TAA (7602918) are the part numbers to be ordered for all customers requiring TAA compliance. The potential difference to the non-TAA is only the location of manufacturing. The physical product is the same in both cases.Q:How to setup a software RAID for boot of X9?A:Software RAID is created, configured, and managed by the OS on the system. You can choose if you wan to boot off the software RAID volume or boot from one device and add the software RAID on different devices. For details refer to the instructions in your operating system documentation.•For Oracle Linux, please refer to Install to A RAID-1 Disk mirror (MOS Doc ID 2326689.1) and How to install Linux OS on RAID Partition (MOS Doc ID 2231802.1)•For Oracle Solaris 11.4, it is strongly recommended to use mirrored ZFS pools. Kindly refer to Installing and Booting Oracle Solaris for more information regarding installation of the operating system.Q:Where can I find more information about Oracle Server X9-2 and Oracle Server X9-2L?A. Contact an Oracle sales representative directly or call1-800-Oracle1 or contact an Oracle authorized reseller. For more information, visit the Oracle x86 servers page.Connect with usCall +1.800.ORACLE1 or visit . Outside North America, find your local office at: /contact. /oracle /oracleCopyright © 2022, Oracle and/or its affiliates. All rights reserved. This document is provided for information purposes only, and the contents hereof are subject to change without notice. This document is not warranted to be error-free, nor subject to any other warranties or conditions, whether expressed orally or implied in law, including implied warranties and conditions of merchantability or fitness for a particular purpose. We specifically disclaim any liability with respect to this document, and no contractual obligations are formed either directly or indirectly by this document. This document may not be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without our prior written permission.This device has not been authorized as required by the rules of the Federal Communications Commission. This device is not, and may not be, offered for sale or lease, or sold or leased, until authorization is obtained.Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group. 0120Disclaimer: If you are unsure whether your data sheet needs a disclaimer, read the revenue recognition policy. If you have further questions about your content and the disclaimer requirements, e-mail ********************.。
Oracle SQL tuning 步骤
1/11
乐沙弥的世界
5、使用索引或物化视图调整SQL访问负载 Oracle 10g之后可以使用SQL Access advisor来为SQL生成索引或物化视图的建议 。应当总是使用索引来优化SQL,特别是基于函数的索引。 Oracle 11g的改进: Oracle 11g中新增的SQL Performance Analyzer (SPA)是一个从整体上加快SQL
记住,你应当总是优先考虑系统级别的SQL tuning,否则在SQL tuning之后再进 行调整可能会使得你先前调整的SQL功亏一篑。 1、优化系统内核 首先应当考虑调整磁盘和网络I/O 子系统(象RAID,DASD带宽,网络等)去最小 化I/O 时间,网络包的大小以及调度频率。 2、调整优化器统计信息 应当定期收集和存储优化器的统计信息以便优化器根据数据的分布生成最佳的执行 计划。此外,直方图有助于优化表的连接以及为有倾斜的 where 子句谓词信息做出正确的访问决定。 3、调整优化器参数 下列优化器参数应当被调整 optimizer_mode, optimizer_index_caching, optimizer_index_cost_adj 4、优化实例 下列实例/会话级别参数将影响SQL性能 db_block_size,db_cache_size, and OS parameters (db_file_multiblock_read_count, cpu_count, &c),
(Oracle管理)Oracle Tuning的一些总结
Oracle Tuning的一些总结关于Oracle的性能调整,一般包括两个方面,一是指Oracle数据库本身的调整,比如SGA、PGA的优化设置,二是连接Oracle的应用程序以及SQL 语句的优化。
做好这两个方面的优化,就可以使一套完整的Oracle应用系统处于良好的运行状态。
本文主要是把一些Oracle Tuning的文章作了一个简单的总结,力求以实际可操作为目的,配合讲解部分理论知识,使大部分具有一般Oracle知识的使用者能够对Oracle Tuning有所了解,并且能够根据实际情况对某些参数进行调整。
关于更加详细的知识,请参见本文结束部分所提及的推荐书籍,同时由于该话题内容太多且复杂,本文必定有失之偏颇甚至错误的地方,请不吝赐教,并共同进步。
1. SGA的设置在Oracle Tuning中,对SGA的设置是关键。
SGA,是指Shared Global Area , 或者是System Global Area , 称为共享全局区或者系统全局区,结构如下图所示。
对于SGA区域内的内存来说,是共享的、全局的,在UNIX 上,必须为oracle 设置共享内存段(可以是一个或者多个),因为oracle 在UNIX上是多进程;而在WINDOWS上oracle是单进程(多个线程),所以不用设置共享内存段。
1.1 SGA的各个组成部分下面用sqlplus 查询举例看一下SGA 各个组成部分的情况:SQL> select * from v$sga;NAME VALUE-------------------- ----------Fixed Size 104936Variable Size 823164928Database Buffers 1073741824Redo Buffers 172032或者SQL> show sgaTotal System Global Area 1897183720 bytesFixed Size 104936 bytesVariable Size 823164928 bytesDatabase Buffers 1073741824 bytesRedo Buffers 172032 bytesFixed Sizeoracle 的不同平台和不同版本下可能不一样,但对于确定环境是一个固定的值,里面存储了SGA 各部分组件的信息,可以看作引导建立SGA的区域。