`
mabel
  • 浏览: 23473 次
  • 性别: 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.

分享到:
评论

相关推荐

    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 ...

    Expert.Oracle.PL.SQL.Techniques.for.Developers.and.DBA.2008

    implemented successfully in real-world projects involving Oracle and PL/SQL. The author appreciates all comments and suggestions to make these “tried- tested-true” techniques “trusted” through ...

    海康威视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

    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"....

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

    教程/考题/范本/读物下载: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 /

    Oracle sqldeveloper without jdk (win+linux)

    Oracle SQL Developer, v1.5.0.54.40 Release Notes 完整版下载:http://www.oracle.com/technology/global/cn/software/products/sql/index.html 1. Known Issues 1.1 General - Print prints only one page ...

    SQLPrompt_7.4.0.471

    Case statements with comments now align correctly Now adds a space before aliases following function calls (forum) Added "Place BEGIN keyword on new line" option Azure support: Visual Studio Azure ...

    aa.rar_https://aa_one more_tube47aa_‘www.aatube.cn

    Top comments Newest first. mark kenneth santos 2 years ago. nice one brod sis :) viva viva magicfive longlive ,,,,, proud to be a dsffcs.. Read more Show less ... Tripoud www.tripoud.com/words/dsffcs ...

    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.1961x64多语言版+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 ...

    comments-posts-wp-api:WP插件可将评论数据插入WordPress JSON API(WP-API)中的posts端点

    这样,无需对/wp-json/posts/ID/comments进行单独的API调用。 安装 解压缩并将comments-posts-wp-api目录上传到/wp-content/plugins/ 通过WordPress中的“插件”菜单激活插件 用法 在URI中添加withcomments 。 ...

    SQLPrompt_7.4.1.603

    Case statements with comments now align correctly Now adds a space before aliases following function calls Added "Place BEGIN keyword on new line" option. You can use this to keep BEGIN on the same ...

    plsql 官方文档

    PL/SQL User's Guide and Reference, 10g Release 1 (10.1) Part No. B10807-01 Oracle welcomes your comments and suggestions on the quality and usefulness of this publication. Your input is an important ...

    SSM开发社交网站SQL文件.sql

    https://blog.csdn.net/weixin_45611051/article/details/108429258#comments_19121894 的SQL文件

    爬取豆瓣影评、清洗、jieba分词、做词云图

    为便于数据清理和词频统计,把eachCommentList列表形成字符串comments,将comments字符串中的“也”“太”“ 的”等虚词(停用词)清理掉后进行词频统计。 3、用词云进行展示 最后使用词云包对影评信息进行词云展示...

    java-sql-import:SQL资源加载和缓存

    sql导入 SQL资源加载和缓存。 从按查询类型组织的可配置标准化目录布局中读取。 查询是每个SqlLoader实例缓存的,因此重复执行同一查询将仅产生一次文件系统I / O开销。 导入函数利用类型。 如果查询不存在或...

Global site tag (gtag.js) - Google Analytics