- 浏览: 804235 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (360)
- Java (101)
- JPA/Hibernate (10)
- Spring (14)
- Flex/BlazeDS (37)
- Database (30)
- Lucene/Solr/Nutch (0)
- Maven/Ant (25)
- CXF/WebService (3)
- RPC/RMI/SOAP/WSDL (1)
- REST (6)
- TDD/BDD/JUnit (1)
- Servlet/JSP (2)
- AI/MachineLearning (3)
- Resource (1)
- 字符编码 (2)
- OOA/OOPS/UML (5)
- DesignPattern (8)
- 算法与数据结构 (11)
- Web&App Server (13)
- 并发&异步&无阻塞 (7)
- Entertainment (4)
- JavaScript/ExtJS (45)
- CodeStyle&Quality (1)
- svn/git/perforce (8)
- JSON (2)
- JavaScriptTesting (4)
- Others (6)
- RegularExpression (2)
- Linux/Windows (12)
- Protocal (2)
- Celebrities (1)
- Interview (1)
- 计算机语言 (1)
- English (2)
- Eclipse (5)
- TimeZone/时区 (1)
- Finance (1)
- 信息安全 (1)
- JMS/MQ (2)
- XSD/XML/DTD (3)
- Android (4)
- 投资 (3)
- Distribution (3)
- Excel (1)
最新评论
-
qdujunjie:
如果把m换成具体的数字,比如4或者5,会让读者更明白
m阶B树中“阶”的含义 -
java-admin:
不错,加油,多写点文章
关于Extjs的mixins和plugin -
xiehuaidong880827:
你好,我用sencha cmd打包完本地工程后,把app.js ...
ExtJS使用Sencha Cmd合并javascript文件为一个文件 -
KIWIFLY:
lwpan 写道inverse = "true&qu ...
Hibernate中什么时候使用inverse=true -
luedipiaofeng:
good
消除IE stop running this script弹出框
Performance and Tuning Series: Query Processing and Abstract Plans
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc00743.1570/html/queryprocessing/title.htm
Query plan/showplan output description
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.dc20022_1251/html/monitoring/X85682.htm
1) set showplan on;
执行sql语句并且显示query plan
2) set showplan on;
set noexec on;
不执行sql语句,只显示sql语句的query plan
3)对于存储过程,使用set fmtonly on
4) set showplan on;
set noexec off;
set statistics plancost on;
会执行sql语句,打印出query plan,同时打印出query plan的图形表示。
有关set statistics plancost on详细信息,请参见《Adaptive Server 参考手册:命令》。此命令用于比较查询计划的估计开销和实际开销。它将其输出显示为表示查询计划树的半图形化的树。这是一种诊断查询性能问题的非常有用的工具。
Also "set statistics io on" is very useful
5. 其他相关set命令
set statistics {io, subquerycache, time, plancost, simulate} {on | off}
显示各种类型的统计信息
• io — 显示有关语句中引用的每个表的统计信息:
• 访问表的次数(扫描计数)
• 逻辑读取的数目(内存中访问的页)
• 物理读取次数(数据库设备访问)
statistics io 为每个命令显示写入的缓冲区数目。
如果 Adaptive Server 已配置为强制资源限制,则 statistics io 还显示
总的 I/O 开销。
• subquerycache — 为每个子查询显示子查询高速缓存中的高速缓存
命中次数、未命中次数和行数。
• time — 显示 Adaptive Server 分析和编译每个命令所用的时间。在
命令的每一个步骤, statistics time 显示 Adaptive Server 执行此命
令所需的时间。时间以毫秒或时钟周期为单位指定,其确切值与
计算机有关。
• plancost — 以树格式显示查询统计信息。
注释 启用 set statistics plancost 后,Adaptive Server 将 lio、pio
和 row 的名称分别缩写为 l、p 和 r。
• simulate — 指定优化程序应使用模拟统计信息来优化查询。
请参见《性能和调优指南》中的第 34 章“使用 set statistics 命令”。
Understanding the Information You Have Gathered
http://infocenter.sybase.com/archive/index.jsp?topic=/com.sybase.39996_1250/html/svrtsg/svrtsg170.htm
You have taken a number of steps to get information about your optimizer problem. Here is an explanation of each of these steps:
select @@version
select @@version displays the version of Adaptive Server you are running, including the SWR level and platform.
sp_help
sp_help provides more accurate information about a table than the script you used to create the table and its indexes. In the event that indexes have been added or changed or that columns have been added via alter table, sp_help will show the present state of the table(s).
set showplan on
The set showplan on command shows which query plan the optimizer has chosen for your query. Use set showplan on before running any query or procedure you will be analyzing.
In some cases you may need to issue the set noexec on command to save time when you are running a very long query. The order of these commands is important:
set showplan on
set noexec on
go
<query text...>
go
There are several important items of information to look for when reading showplan output:
Cache Utilization
Adaptive Server uses two major strategies, named LRU and MRU respectively, for its data cache. The type of strategy used in a given query depends on whether a cached page needs to be accessed more than once. showplan’s "Buffer Replacement Strategy" messages show the cache strategy used for data pages and index leaf pages. See “Caches and Object Bindings” in the Performance and Tuning Guide for more information about cache strategies.
If you want to investigate your caches, for example to learn whether a cache is under- or over-utilized, you can use sp_sysmon. See “Data Cache Management” in the Performance and Tuning Guide.
Index Utilization
Was an index used? Which one? Was a table scan done? To answer these questions, check the portion of showplan output following FROM TABLE for messages like "Table Scan" or "Using Clustered Index".
Join Information
When evaluating joins, look for
the order of tables in a join, also known as join order; knowing the order that the optimizer chose for joins is critical to your analysis. When your query joins two or more tables, showplan’s FROM TABLE messages show the order in which the optimizer will join the tables.
Whether it is a nested-loop join or a sort-merge join (applies to 12.0 and later).
Refer to “Using set showplan” in the Performance and Tuning Guide for more information on interpreting showplan results.
set statistics io on
Since any analysis of a performance problem will require knowledge of the number and types of I/Os performed for the query, the set statistics io on command is critical.
NoteIf your query is taking very long to complete, using statistics io and statistics time may not be feasible. If you analyze your long-running query using set noexec on, you cannot obtain I/O information since noexec on stops all the output of statistics io.
The set statistics io on command provides you with the following information:
Physical reads
This is the number of times Adaptive Server accesses the disk. The first time a query is run, the number of physical reads will generally be high. This happens because the required pages are not usually in cache. Subsequent runs of the query can access the pages in cache, and physical reads are minimized, if not avoided. If the number of physical reads remains high during subsequent executions of a query, you will need to take a close look at how the query executes.
In some instances, the size of the data cache may also be a problem. If it is too small, pages have to be read from disk more often. Likewise, configuration of named caches and use of large I/O buffer pools can have an impact on performance. See “Memory Use and Performance” in the Performance and Tuning Guide for details on configuring the data cache to improve performance.
Logical reads
Logical reads are a combination of physical reads and "cache hits" - reads from pages in cache. If your statistics show a number of logical reads and no physical reads, it means that all required pages are in cache, which is the ideal situation. To determine the cache hit ratio (the percentage of pages that were found in cache) for your query, use the formula:
Logical reads - (Physical reads * Pages per I/O)
Cache hit ratio = -----------------------------------------------
Logical reads
Use set showplan on to see the I/O size used by the query. With 2K pages, a query using 4K I/O reads 2 pages with each I/O.
Scan count
This is the number of times the table was read (using either a table scan or an index) in order to find rows to satisfy the query or join. In nearly all simple single table queries, the scan count will be 1. When an OR clause is present there will be one scan count for each OR in the query. In the case of a join, the scan count can be crucial.
If the optimizer chose a bad join order, you are likely to see a very high number of scan counts on a large table, causing a very high number of logical reads. However, you should take the table size into account when interpreting scan counts. A high scan count on a small table is preferable to a moderate scan count on a large table. Although the scan count of the small table is high, the physical reads should be low. A 1000-scan count for a 1-page table is better than a 100-scan count of a 1000-page table.
The following example demonstrates how join order and scan count affect the number of reads (on 12.0 and later, the example represents a nested-loop join):
Table A has 1 page and 10 rows that qualify for the join. Table B has 1000 pages and 10 rows that qualify for the join.
If Table B is the outer table of the join Adaptive Server will only need to read through it once in order to find all qualifying rows. The single scan totals 1000 reads. Adaptive Server then reads Table A for each qualifying row found in B. The single page in A is scanned 10 times, equaling 10 reads, with a total of 1010 reads for the query. If A were the outer table Adaptive Server would have to read B once for each of the ten qualifying rows on A: 1000 pages multiplied by 10 scans equals 10,000 reads.
This example assumes that there is no useful index available.
Total writes for this command
This is the total number of writes Adaptive Server did for the query. This count includes inserts, updates and deletes on user tables, temporary tables and work tables. Even queries that do not include data manipulation statements may require writes to work tables or temporary tables, which are counted here.
set statistics time on
set statistics time on provides the following information:
Adaptive Server elapsed time
This is the total accumulated elapsed time that is recorded for the query or command. This can seem long if, for example, a query was blocked by a lock, network traffic or other resource contention. The time the query must wait for the blockage to clear is added to the elapsed time.
Adaptive Server CPU time
This is the amount of time for which the query had exclusive use of the CPU. It reflects the time taken to parse, compile, and execute the query. Functions add to the CPU time. For example, a convert statement will increase the CPU time slightly. Also, compute-intensive queries and queries that perform a large amount of I/O take more CPU time.
The output of set statistics time on may be useful, but it is not usually a significant factor in most optimizer analyses.
dbcc traceon (3604)
This trace flag sends the output of dbcc traceon (302) and dbcc traceon (310) to the screen.
dbcc traceon (302)
This trace flag returns the optimizer's cost estimates for each SARG and join clause in the query. Trace flag 302 is documented in greater detail in “Tuning with dbcc traceon” in the Performance and Tuning Guide.
Here is the information to watch for in dbcc traceon (302) output:
All SARGs and join clauses in the query should be shown in the optimizer's cost estimates. If not, determine why.
Check that row and page counts are accurate, since these counts are important for optimization.
If you think that the page and row counts are off, check the counts. Run optdiag statistics. To improve performance, counts and other statistics are changed in memory and flushed to systabstats periodically by the housekeeper task. You can also flush in-memory statistics to systabstats by running optdiag statistics or executing sp_flushstats table_name.
dbcc traceon (310)
dbcc traceon (310) gives the optimizer cost estimates for permutations of a join or joins. Examine the dbcc traceon (310) output to determine whether the query is “connected.” If so, it indicates that the join will not result in a cartesian product. The statement “query is connected” will appear after the optimizer has performed cost estimates on all possible indexes, as indicated in the output of dbcc traceon (302) .
IO statistics output explanation
below is one row of the output when set statistics io on for q query
Table: Worktable1 scan count 1, logical reads: (regular=6391 apf=0 total=6391), physical reads: (regular=7919 apf=0 total=7919), apf IOs used=0
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.dc20022_1251/html/monitoring/monitoring99.htm
Statistics for reads
statistics io reports the number of logical and physical reads for each table and index included in a query, including worktables. I/O for indexes is included with the I/O for the table.
Table 4-1 shows the values that statistics io reports for logical and physical reads.
Table 4-1: statistics io output for reads
logical reads
regular
Number of times that a page needed by the query was found in cache; only pages not brought in by asynchronous prefetch (APF) are counted here.
apf
Number of times that a request brought in by an APF request was found in cache.
total
Sum of regular and apf logical reads.
physical reads
regular
Number of times a buffer was brought into cache by regular asynchronous I/O
apf
Number of times that a buffer w.as brought into cache by APF.
total
Sum of regular and apf physical reads.
apf IOs used
Number of buffers brought in by APF in which one or more pages were used during the query.
发表评论
-
mysql,oracle,sql server中的默认事务隔离级别
2018-08-02 17:03 700mysql,oracle,sql server中的默认事务隔离 ... -
创建前缀索引报长度超出错误
2018-07-25 15:44 1731表结构定义如下: CREATE TABLE `sku` ( ` ... -
Mysql Varchar字符长度
2018-07-25 15:23 1352`sku_name` VARCHAR(200) NOT NUL ... -
Mysql分表和分区的区别、分库分表介绍与区别
2017-06-14 20:32 1852Mysql分表和分区的区别、分库分表介绍与区别 http:// ... -
Nested Loop Join和子查询
2017-06-03 20:56 731这2个是不同的概念,不要混淆在一起了 Nested Loop ... -
oracle中rownum和rowid的区别
2017-06-03 20:55 1007oracle中rownum和rowid的区 ... -
分布式事务XA,JTA,两阶段提交,BASE
2016-06-27 21:45 5680关于分布式事务、两阶段提交、一阶段提交、Best Effort ... -
大数据技能图谱
2016-03-24 13:33 865http://mp.weixin.qq.com/s?__biz ... -
Java 方法(JdbcTransactionTemplate)与存储过程共享同一个事务
2016-01-12 19:24 1713如果要让java来管理事务,那么在存储过程里不能写提交(com ... -
Java 平台开发有效事务策略,数据库事务性能
2016-01-11 15:42 871Java 平台开发有效事务策略系列文章 http://www. ... -
SQL语句的where字句表达式顺序影响性能吗?
2015-09-09 13:45 1953比如下面的SQL语句性能有区别吗? select * from ... -
Sybase database Transaction mode: chained and unchained
2015-09-02 10:15 1451Support for Sybase database Tra ... -
聚集索引,非聚集索引,主键,索引类型及实现方式
2015-08-06 11:31 817聚集索引和非聚集索引(整理) http://www.cnblo ... -
Sybase性能调优建议清单
2015-03-17 15:57 1253http://stackoverflow.com/questi ... -
left join时on条件与where条件的区别
2015-03-09 17:46 3430参考文章:http://cqujsjcyj.iteye.com ... -
Sybase常用命令,SQL语句
2014-10-22 16:44 5005SQL online sample http://sqlzoo ... -
数据库系统基本概念
2014-07-02 18:47 1378数据模型(Data Model)是描述数据、数据联系、数据语义 ... -
乐观锁与悲观锁
2014-06-09 11:57 663Key points: 悲观锁的实现,往往依靠数据库提供的锁机 ... -
数据库事务,锁,隔离级别(Isolation Level)
2014-06-09 11:44 2194数据库的隔离级别2(repeaable read)可实现重 ... -
我的Oracle学习笔记
2014-05-18 13:31 0以前工作中整理的oracle学习笔记,虽然有些凌乱,但是时候自 ...
相关推荐
**Sybase SQL Anywhere 5.0** 是一个强大的数据库管理系统,特别设计用于移动和分布式环境。这个版本在20世纪90年代末发布,它提供了高效的数据存储、管理和访问功能,尤其适合那些需要在远程位置或者离线环境中运行...
**Sybase ASE SQL Expert** 是一个专为Sybase Adaptive Server Enterprise (ASE)设计的专业数据库管理工具,用于优化SQL查询性能和提升数据库管理效率。Sybase ASE是Sybase公司推出的一款高性能的关系型数据库管理...
8. **故障诊断与优化**:文档可能包含故障排查步骤和性能优化技巧,帮助用户解决常见问题,提升数据库运行效率。 综上所述,《Sybase ASA(SQL Anywhere 12.0.0)中文文档全集.chm》是深入学习和应用SQL Anywhere ...
### Sybase数据库SQL过程详解 #### 系统过程概述 Sybase数据库中的系统过程是预定义的过程,主要用于管理和查询数据库的内部信息。这些过程能够帮助DBA或开发人员执行诸如查看表结构、索引信息、用户权限等操作,...
- **故障排查**:错误日志分析、性能问题诊断和解决方法。 - **数据库维护任务**:如碎片整理、统计信息更新和数据库收缩。 通过这些文档,用户可以全面了解Sybase SQL Anywhere 10,从安装到日常使用,再到高级...
7. **数据库调优工具**:SYBASE提供了一系列工具,如ASE Profiler、dbcc命令,用于监控和诊断性能问题,这些工具的使用也是优化的重要环节。 8. **系统资源管理**:包括CPU调度、IO调度、网络优化等,都需要根据...
8. **日志记录**:为了跟踪工具的运行情况和诊断问题,源代码可能包含日志记录功能,记录SQL执行的详细信息,如执行时间、结果、错误信息等。 9. **性能优化**:在处理大量数据或频繁查询时,可能需要考虑性能优化...
而Sybase SQL Server作为知名数据库系统,能提供高性能的数据库服务,两者结合,适合构建分布式的企业信息系统。 6. **总结** PowerBuilder与Sybase SQL Server的网络通信实现涉及多个层次,从用户界面到数据库...
根据给定的信息,本文将详细解释Sybase数据库中常见的SQL操作问题及解决方法,并通过具体的命令和示例来深入...通过上述命令和方法,我们可以有效地管理和优化Sybase数据库中的SQL操作,提高数据库的整体性能和稳定性。
第三卷《监控和分析性能工具》专注于如何使用Sybase提供的监控和分析工具来诊断和解决性能问题。这部分可能涵盖性能监控的关键指标,如CPU使用率、磁盘I/O、内存消耗、锁等待等,以及如何使用Sybase的Profiler、SQL ...
### Sybase SQL Server 性能与调优指南 #### 概述 《Sybase SQL Server 性能与调优指南》是一本专为Sybase SQL Server数据库管理员和技术人员设计的技术文档,旨在帮助用户理解并优化Sybase SQL Server的性能。...
### SYBASE ASE 性能调优详解 #### 一、性能定义及度量方法 **性能**是指在特定环境中衡量应用程序或系统的效率。对于Sybase Adaptive Server Enterprise (ASE) 来说,性能主要包括两个方面: 1. **响应时间**:...
8. **性能监控和诊断工具**:Sybase提供了一系列工具,如Profiler和Query Performance Analyzer,用于追踪和分析SQL性能问题。掌握这些工具的使用方法是识别瓶颈和进行调优的关键。 9. **物理设计**:表的分区、...
3. **Monitor**:Monitor能够提供实时的性能统计数据,帮助我们快速诊断当前存在的性能问题。 4. **Trace**:Trace功能可以记录下所有的数据库活动,这对于深入分析特定时间段内的性能问题非常有帮助。 #### 性能...
综上所述,针对 Sybase ASE 12.5 的性能优化涉及多个层面,包括 SQL 语句优化、参数配置调优、硬件资源利用等多个方面。在实际操作过程中还需结合具体应用场景灵活运用各种技术和方法,以达到最佳效果。希望本文能够...
- 通过查询计划可以诊断和优化查询性能问题。 12. **控制查询处理** - 设置查询时间限制、查询优先级等参数可以更好地控制查询的执行。 13. **设置查询优化选项** - 调整查询优化选项可以改善查询性能。 14. *...
### SYBASE性能及调优指南 Volume 1 #### 基础知识篇 在深入了解Adaptive Server中的性能问题之前,我们需要掌握一系列的基础知识。这部分内容将帮助我们更好地理解数据库性能优化的基本概念和技术。 ##### 一、...
在Sybase Adaptive Server Enterprise (ASE)数据库管理系统中,MDA(Metadata Data Access)是一种强大的工具,用于监控和分析数据库的性能问题。MDA提供了一种方法来深入了解ASE的内部工作原理,通过收集和分析关于...
6. **性能监控**:实时监控数据库性能,包括查询执行时间、内存使用情况、磁盘I/O等,帮助用户诊断和优化性能问题。 7. **脚本编辑器**:内置的SQL脚本编辑器支持编写、调试和运行复杂的SQL语句。 8. **报告生成**...