`
mabel
  • 浏览: 24180 次
  • 性别: Icon_minigender_2
最近访客 更多访客>>
社区版块
存档分类
最新评论

Do comments slow down PL/SQL? 备注会降低PL/SQL性能么?

阅读更多

quoted from    http://blogs.techrepublic.com.com/programming-and-development/?p=507&tag=nl.e050 

没时间整理出来。 大家将就看看哈~

I’m not sure where this started, but at work there’s this rumor going around that if you put too many comments in an Oracle PL/SQL package, it impacts performance. That is, the more comments in your code the slower it runs.

I could kind of understand if the language was interpreted because the comments would have to be read in by the interpreter and thus could have an impact on performance. But PL/SQL gets compiled in the database, so I did not see how comments could be a problem.

There’s only one way to really tell, of course, and that’s to run experiments. So, doing my best MythBusters imitation, I decided to take a crack at it.

I started by creating a table called TABLE1 (sorry, I was lazy and just used the table name that SQLDeveloper gave me). The table had three fields: a varchar to store the name of the method and two timestamp fields for the start and end times. The DDL looked something like this:

create table TABLE1
  (  methodname VARCHAR2(255 BYTE),
     starttime TIMESTAMP (6),
     endtime TIMESTAMP (6)
   )

Then I created a package with two methods. The basic code in both methods was identical. Here’s the code from the version without comments:

procedure comments_n AS
    counter integer := 0;
    starttime timestamp;
  BEGIN
    starttime := current_timestamp;    

    while counter < 9999999 loop
      counter := counter + 1;
    end loop;    

    insert into Table1(methodname, starttime, endtime)
    values ('comments_n', starttime, current_timestamp);    

    commit;    

  END comments_n;

The second method, called comments_y, was identical, except I liberally sprinkled single-line and multi-line comments everywhere. And, yes, I put comments inside the loop since that’s where most of the time will be spent in this method.

I then called the methods with a little anonymous block, like this:

begin
  pkg_timingtest.comments_n;
  pkg_timingtest.comments_y;
end;

The first five times through I called the procedure without comments first; then I edited this anonymous block so that the procedure with comments got called first. I re-ran it another five times. When that was done, I averaged up the time differences and grouped them by the method name:

select
  methodname,
  avg ((extract(second from (endtime - starttime))) * 1000) as diff
from table1
group by methodname;

I repeated this experiment several times. On some runs, the method with comments would average faster times than the one without. In those cases where the method with comments was slower on average, it was by just two or three milliseconds, which is not a significant percentage when the average runtime was over 2,400 milliseconds.

I consider this myth busted.

分享到:
评论

相关推荐

    PL/SQL 创建 oracle 任务调度

    在PL/SQL环境中,有两种主要的方法来创建Oracle任务调度:可视化创建和通过代码创建。 **方法一:直接在PL/SQL中可视化创建** 此方法适合对界面操作熟悉的用户。在PL/SQL Developer工具中,你可以直接通过图形化...

    plsql乱码解决办法

    在使用 PL/SQL Developer 查询数据时,我们可能会遇到两个问题:一是表结构中的 comments 中文乱码;二是查询结果集中文乱码。 问题分析 当我们安装 PL/SQL Developer 后,默认情况下,系统的字符集设置可能不是...

    PLSQL Developer 11 中文绿色版

    PL/SQL Developer 11.0 - New Features Below you can find a brief description of the most important new features in PL/SQL Developer 11.0. New features SQL Window enhancements The result set toolbar ...

    plsqldev14.0.0.1961x32多语言版+sn.rar

    For these file control operations PL/SQL Developer relies on a 3rd party shell extension that must be installed on your system. In the screenshots above “GIT Extensions” has been used. Worksets A ...

    PLSQL教學講義.doc

    PL/SQL是Oracle数据库系统中的一个强类型编程语言,它扩展了SQL的语法,使得开发者可以编写复杂的存储过程、函数、触发器等数据库应用程序。在本篇PLSQL教学讲义中,我们将深入探讨其基本结构、变量类型、数据类型、...

    PLSQL开发过程中,动态使用DBMS_SQL[借鉴].pdf

    在 PL/SQL 开发过程中,使用 SQL、PL/SQL 可以实现大部分的需求,但是在某些特殊的情况下,在 PL/SQL 中使用标准的 SQL 语句或 DML 语句不能实现自己的需求,比如需要动态建表或某个不确定的操作需要动态执行。...

    海康威视WEB3.0多版本开发控件.zip

    海康威视WEB3.0,包含官方控件:CH_32位、CH_64位、CN_64位、火狐浏览器:4.00/45.0/50.0.1、IE浏览器:IE7-32位/64位。具体操作:https://blog.csdn.net/concealed0/article/details/88637413#comments

    sql--常用sql语句查询

    根据给定的文件标题、描述、标签以及部分内容,我们可以总结出一系列与SQL查询相关的知识点,主要聚焦于数据库管理和数据检索方面。以下是对这些知识点的详细解释: ### SQL基础查询语句 1. **查找含有特定关键词...

    plsqldev13.0.3.1902x32主程序+ v12中文包+keygen

    32位版本的 PLSQL 正式版。 安装中文包时请注意安装路径是否为PLSQL程序的路径。 安装请查看说明。...An error message about "GetTickCount64" could appear when starting PL/SQL Developer on Windows XP

    plsqldev13.0.3.1902x64主程序+ v12中文包+keygen

    64位版本的 PLSQL 正式版,只能运行在64位系统中,需要你安装 64 位的 Oracle11g 或 Oracle12c 客户端。...An error message about "GetTickCount64" could appear when starting PL/SQL Developer on Windows XP

    PLSQL Developer 8.0.3.1510 中文注册版下载

    Enhancements in PL/SQL Developer 8.0.3 ====================================== * Fixed Access Violation when dragging & dropping an empty item in the Logon History * Fixed Access Violation in the File...

    PLSQL.Developer v11.0.4.1774 主程序+ v11中文包+keygen

    PL/SQL Parser did not process double quoted identifiers with quotes and comments correctly Code Assistant did not work for aliases for table names in double quotes Right-click on a quoted "OWNER"....

    PLI Language Reference

    每个版本的 PL/I 都会有新的增强功能,这些增强通常包括性能优化、新特性引入或错误修复等。文档中详细列举了自 V3R1 以来各版本的增强功能,这对于了解 PL/I 的发展历史及其技术进步非常有用。 #### 六、反馈机制 ...

    最新毕业论文开题报告模板 下载

    教程/考题/范本/读物下载:http://zl.mydown.com 读编交流区:http://comments.yesky.com/t/212860/0,0/0.shtml 驱动下载:http://drivers.yesky.com 读编交流区:http://comments.yesky.com/t/212864/0/0.shtml...

    blog-fake-api:博客伪造的API,可将其与您的前端MV * JS一起使用

    博客虚假API 用它来玩您的前端MV * JS。安装: npm install跑步: npm start...id=1&id=2GET /comments?user.name=John片添加_start和_end或_limit (响应中包括X-Total-Count标头) GET /posts?_start=20&_end=30GET /

    PowerDesigner导出的SQL带列注释,导入到MySQL中列注释不见了的处理方法

    PowerDesigner 导出的 SQL 带列注释,导入到 MySQL 中列注释不见了的处理方法 在使用 PowerDesigner 导出 SQL 文件时,如果包含列注释,可能会在导入到 MySQL 数据库中时丢失。这是因为 PowerDesigner 导出的 SQL ...

    微信小程序实现城市选择效果city.js文件

    微信小程序实现城市选择效果, 可以先看一下效果,这里我附带我的另一个博客,有详细的用法https://blog.csdn.net/qq_42543264/article/details/106396354#comments_13793530

    Oracle9i spool续写实例

    Oracle的Spool功能是数据库管理员和开发人员常用的一种工具,用于将SQL查询结果或PL/SQL块的输出重定向到文本文件中,而非在屏幕显示。在Oracle 10g及更高版本中,Spool引入了`CREATE`, `REPLACE`, 和 `APPEND` 参数...

Global site tag (gtag.js) - Google Analytics