`
dbaspider
  • 浏览: 262136 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

Oracle hard-parse vs. soft parse

阅读更多
Oracle hard-parse vs. soft parse

OracleSQLCache .

Oracle SQL is parsed before execution, and a hard parse includes these steps:

1.Loading into shared pool - The SQL source code is loaded into RAM for parsing. (the "hard" parse step)

2.Syntax parse - Oracle parses the syntax to check for misspelled SQL keywords.

3.Semantic parse - Oracle verifies all table & column names from the dictionary and checks to see if you are authorized to see the data.

4.Query Transformation - If enabled (query_rewrite=true ), Oracle will transform complex SQL into simpler, equivalent forms and replace aggregations with materialized views, as appropriate.

5.Optimization - Oracle then creates an execution plan, based on your schema statistics (or maybe with statistics from dynamic sampling in 10g).

6.Create executable - Oracle builds an executable file with native file calls to service the SQL query.

Oracle gives us the shared_pool_size parm to cache SQL so that we don't have to parse, over-and-over again.  However, SQL can age-out if the shared_pool_size is too small or if it is cluttered with non-reusable SQL (i.e. SQL that has literals "where name = "fred" ) in the source.

What the difference between a hard parse and a soft parse in Oracle?  Just the first step, step 1 as shown in red, above.  In other words, a soft parse does not require a shared pool reload (and the associated RAM memory allocation).

A general high "parse call" (> 10/sec.) indicates that your system has many incoming unique SQL statements, or that your SQL is not reentrant (i.e. not using bind variables).

A hard parse is when y our SQL must be re-loaded into the shared pool.  A hard parse is worse than a soft parse because of the overhead involved in shared pool RAM allocation and memory management.  Once loaded, the SQL must then be completely re-checked for syntax & semantics and an executable generated. 

Excessive hard parsing can occur when your shared_pool_size is too small (and reentrant SQL is paged out), or when you have non-reusable SQL statements without host variables.

See the cursor_sharing parameter for a easy way to make SQL reentrant and remember that you should always use host variables in you SQL so that they can be reentrant.


分享到:
评论

相关推荐

    oracle动态性能表

    注:SQL语句的解析有软解析soft parse与硬解析hard parse之说,以下是5个步骤: 1:语法是否合法(sql写法) 2:语义是否合法(权限,对象是否存在) 3:检查该sql是否在共享池中存在 -- 如果存在,直接跳过4和5,运行sql....

    oracle 性能优化

    - **Parses、Hard Parses、Soft Parses**:Parses是解析SQL语句的过程。Hard Parse是首次解析,需要编译和创建执行计划;Soft Parse则是在共享池中找到相同或相似的解析树,避免了硬解析的开销。 2. **执行计划...

    oracle动态性能视图

    V$SYSSTAT中的数据通常被用于监控系统性能指标,例如缓存命中率(Buffer Cache Hit Ratio)和软解析率(Soft Parse Ratio)。缓存命中率是衡量数据库性能的重要指标之一,它反映了数据读取操作在缓存中找到所需数据...

    Oracle专家白鳝 从一个案例看性能优化与系统优化.pdf

    - Soft Parse%:软解析比率 - Execute to Parse%:执行到解析比率 - Latch Hit%:锁存命中率 - Parse CPU to Parse Elapsed%:解析CPU与解析时间比率 - Non-Parse CPU:非解析CPU使用率 - **等待事件**: - ...

    Oracle AWR 报告分析实例讲解.docx

    - **软解析(Soft Parse)**:当相同的SQL再次执行时,Oracle会尝试复用已有的解析树和执行计划,从而避免重复工作。 - **优化建议**:为提高性能,应尽量减少硬解析,通过合理的SQL重用策略提高软解析比例。 5. **...

    oracle变量绑定[文].pdf

    首先,不使用绑定变量会导致SQL语句的硬分析(Hard Parse)过于频繁。当Oracle遇到一个SQL语句时,它会检查其在Shared Pool(内存区域)中是否存在相同的语句。如果不存在,就会进行硬分析,检查涉及的对象的有效性...

    oracle内存管理,深入浅出oracle内存管理,盖国强oracleppt

    在这个过程中,软解析(soft parse)是指如果在Library Cache中找到已解析的SQL,而硬解析(hard parse)则表示需要重新解析SQL。 7. **CBO与RBO**:Cost-Based Optimizer(CBO)和Rule-Based Optimizer(RBO)是...

    STATSPACK report

    - **Soft Parse %**: 88.99 - **Execute to Parse %**: -18.96 - **Latch Hit %**: 99.90 - **Parse CPU to Parse Elapsd %**: 34.20 - **% Non-Parse CPU**: 99.67 ### 6. **共享池统计信息** - **Memory Usage %...

    【Oracle性能调优】OracleStatspack报告中各项指标含义详解[归类].pdf

    6. Soft Parse Ratio(软解析比率) 软解析比率是指 SQL 语句的软解析比率,通常在 90% 以上。如果太低,可能需要调整应用程序使用绑定变量。 7. Latch Hit Ratio(锁命中率) 锁命中率是指内部结构维护锁的命中...

    D17265GC10 - Oracle Database 10g:SQL Tuning Workshop

    硬解析(Hard Parse)则会消耗大量系统资源,而软解析(Soft Parse)则利用绑定变量重用解析计划,减少系统开销。 6. **索引策略**: - 选择合适的索引类型(B树、位图、函数索引等)对查询性能至关重要。理解何时...

    Oracle内存分配与调整 pdf

    例如,如果v$sgastat显示共享池中的频繁软解析(soft parse)或硬解析(hard parse),可能意味着共享池配置不足,需适当增加shared_pool_size。 #### 五、结论 综上所述,Oracle的内存管理是数据库性能优化的关键环节...

    oracle数据库优化

    软解析(Soft Parse)和硬解析(Hard Parse)是解析过程的两种形式。软解析只需进行语法和语义检查,如果在共享池中找到相同的语句,就直接执行。而硬解析则涉及更复杂的优化过程,包括视图合并、谓词下推、子查询...

    Oracle_AWR_报告分析实例讲解.docx

    - **Soft Parse (软解析)**: 当Oracle收到SQL语句后,会先对其进行语法和语义检查,然后通过内部算法生成解析树和执行计划。在生成执行计划之前,Oracle会利用内部的hash算法计算SQL的hash值,并在 **Library Cache*...

    学习动态性能表_all_in_one

    硬解析(Hard Parse)和软解析(Soft Parse)是数据库性能的关键指标。硬解析会带来较高的CPU和资源开销,因为它需要解析SQL并重新分配内存。软解析则利用已存在于Shared Pool中的SQL语句,节省了资源。软解析命中率...

    ORACLE数据库变得非常慢解决方案一例.pdf

    2. **优化SQL查询**:硬解析(Hard Parse)较少,但软解析(Soft Parse)仍有优化空间。检查SQL语句,优化查询语句,避免全表扫描,减少I/O密集型操作。 3. **监控和调整Latches**:高频率的latch free事件可能意味...

    数据库调优:ORACLE EXPLAIN PLAN的总结

    7. **使用绑定变量**:避免在SQL语句中使用硬解析(hard parse),即每次执行都创建新的执行计划。使用绑定变量(bind variables)可以实现软解析(soft parse),复用相同的执行计划,提高效率。 8. **监控与调整*...

    Oracle 中的变量绑定

    不使用绑定变量,例如在Java程序中直接将变量值拼接到SQL语句中,会导致每次SQL语句的值改变时,Oracle都需要重新解析SQL,这称为硬分析(Hard Parse)。硬分析不仅消耗CPU资源,还会增加数据库的负载,因为每次都...

    相克军 ORACLE 讲座 shared pool 笔记

    在数据库操作中,解析SQL语句有两种方式:硬解析(Hard Parse)和软解析(Soft Parse)。硬解析是当SQL首次提交时,由于数据库需要进行完整的语法检查、权限验证和执行计划生成,因此消耗资源较多。相反,软解析是在...

    ORACLE资源详解

    这包括快速解析(fast parse)、软解析(soft parse)和硬解析(hard parse)。软解析次数过高可能意味着应用程序效率不高。 - **Soft parses**:当SQL语句在共享池(shared pool)中找到匹配的解析树时发生的解析操作。高...

Global site tag (gtag.js) - Google Analytics