zoukankan      html  css  js  c++  java
  • How to show query plan and runtime statistic in Derby

    The official websie (http://db.apache.org/derby/) has straightford description. I just try to highlight some features:

    • an open source, under the Apache License, Version 2.0 .
    • relational database
    • entirely in Java
    • 2 megabytes for the base engine and embedded JDBC driver
    • embedded or client/server mode

    check out the Quick Start page if you want to know more.

    I will give my experience on check the query plan, runtime statistic, which is very useful to tune the performance.

    Query Plan

    To show the query plan, first create file named “derby.properties ” under derby “lib” directory, and put following lines:

    derby.language.logQueryPlan=true
    derby.optimizer.noTimeout=true

    You must manully create the file! Then start derby ij command line [1], after run the query, the query plan is recorded in the “derby.log” file.The log will show you the detail on how the query engine analysis the user's query and optimize the query. You can find the the final query sequence and whether index is used or not and which one.

    Runtime Statictic

    But you can not get the real runtime for the query just display the query plan. Here is some way to show it:

    In ij command

    1. MaximumDisplayWidth 9999; (if you query is simple, ignor it. If complex, must set. For my case, even set it still not big enough. Try next two methods)
    2. CALL SYSCS_UTIL.SYSCS_SET_RUNTIMESTATISTICS(1);
    3. CALL SYSCS_UTIL.SYSCS_SET_STATISTICS_TIMING(1);
    4. Run your statement (like select * from table; )
    5. VALUES SYSCS_UTIL.SYSCS_GET_RUNTIMESTATISTICS();

    Directly run java command

    java -cp .;derby.jar;derbytools.jar java org.apache.derby.tools.ij my.sql > myoutput.txt

    This will run a sql file and dump the result out to a file. Here is a sample "my.sql" file:


    Note: I call a usre-defined function named "myED" in the script.

    Using Java

    Reference:

    [1]http://db.apache.org/derby/integrate/plugin_help/ij_toc.html

    [2]http://db.apache.org/derby/docs/dev/tools/ttoolsij98878.html

    [3]http://db.apache.org/derby/docs/dev/tools/ttoolsij98878.html

    [4]https://www.ibm.com/developerworks/forums/thread.jspa?threadID=122245&tstart=0&messageID=13833605

    [5]http://home.online.no/~olmsan/publications/pres/javaone07/JavaDbJavaOne07.pdf

  • 相关阅读:
    ◆◆0[问题解决]REUSE_ALV_FIELDCATALOG_MERGE丢失catalog字段
    不同类型ALV的catalog数据转换[LVC_TRANSFER_TO_SLIS][LVC_TRANSFER_FROM_SLIS]
    ◆◆0ABAP ALV分类以及对应的函数,类小结
    [代码]如何在ALV头中显示Logo图片-[REUSE_ALV_GRID_DISPLAY]
    ◆◆0SALV-如何刷新显示
    ◆◆0[REUSE_ALV_GRID_DISPLAY_LVC]-显示单选按钮(radio button)
    ◆◆0[REUSE_ALV_GRID_DISPLAY_LVC]ALV中字段显示前导零(leading zero)
    ◆◆0[REUSE_ALV_GRID_DISPLAY_LVC]-显示布局按钮(layout button)
    [问题解决]ALV标准过滤功能失效
    ◆◆0SALV-设置SALV选择模式
  • 原文地址:https://www.cnblogs.com/ainima/p/6331347.html
Copyright © 2011-2022 走看看