{"id":161,"date":"2009-04-11T12:18:46","date_gmt":"2009-04-11T06:18:46","guid":{"rendered":"http:\/\/techsatwork.com\/blog\/?p=161"},"modified":"2016-01-07T11:31:13","modified_gmt":"2016-01-07T05:31:13","slug":"nice-to-meet-you-db2batch","status":"publish","type":"post","link":"https:\/\/techsatwork.com\/?p=161","title":{"rendered":"Nice to meet you db2batch !"},"content":{"rendered":"<p>I have been using db2batch for a while now. The more I use it, the more I like it. It can give you very useful information about your query that can help you tune it. \u00c2\u00a0It can give you execution \/ run time information, run it under certain optimization level, give you explain information, database snapshot , dbm snapshot, table snapshot information while the query is running. \u00c2\u00a0There is one\u00c2\u00a0caviar\u00c2\u00a0to it, by default db2batch execute the query in RR isolation level. This is not desirable if the query is long running and is run against production system as it may cause locking issue and might even hang the system. So I suggest you change the\u00c2\u00a0isolation\u00c2\u00a0level of the db2batch to CS \u00c2\u00a0if you are going to run it against production or against any system which is busy. \u00c2\u00a0You can do so by binding the db2batch.bnd found on \/sqllib\/bin directory with isolation cs :<\/p>\n<address><em>db2 bind db2batch.bnd isolation cs blocking all grant public<\/em><\/address>\n<p>db2batch does a good job of benchmarking the sqls. \u00c2\u00a0There are several options you can use in db2batch, I am not going to mention all of it here. You can find it on<a href=\"http:\/\/publib.boulder.ibm.com\/infocenter\/db2luw\/v9r5\/index.jsp?topic=\/com.ibm.db2.luw.admin.cmd.doc\/doc\/r0002043.html\" target=\"_blank\"> DB2 manuals<\/a>, but here is a basic one I always use :<\/p>\n<p>db2batch -d rajudb -f \u00c2\u00a0sqlfile1.sql \u00c2\u00a0-r result_sqlfile1.txt \u00c2\u00a0-o p 1 e 2<\/p>\n<p>This will connect to the database rajudb , run the sql in the file sqlfil1.sql and send the output to result_sqlfile1.txt . The -o options enables me to specify the level of performance detail and explain done on the table. Refer to the <a href=\"http:\/\/publib.boulder.ibm.com\/infocenter\/db2luw\/v9r5\/index.jsp?topic=\/com.ibm.db2.luw.admin.cmd.doc\/doc\/r0002043.html\" target=\"_blank\">manual<\/a> to find details about it.\u00c2\u00a0<\/p>\n<p>Here is sample output I got from the above run :\u00c2\u00a0<\/p>\n<p><span style=\"text-decoration: underline;\"><a href=\"https:\/\/techsatwork.com\/blog\/wp-content\/uploads\/2009\/04\/picture-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-large wp-image-174 alignleft\" title=\"result_sqlfile1.png\" src=\"https:\/\/techsatwork.com\/blog\/wp-content\/uploads\/2009\/04\/picture-3-1024x596.png\" alt=\"result_sqlfile1.png\" width=\"502\" height=\"292\" srcset=\"https:\/\/techsatwork.com\/wp-content\/uploads\/2009\/04\/picture-3-1024x596.png 1024w, https:\/\/techsatwork.com\/wp-content\/uploads\/2009\/04\/picture-3-300x174.png 300w, https:\/\/techsatwork.com\/wp-content\/uploads\/2009\/04\/picture-3.png 1196w\" sizes=\"auto, (max-width: 502px) 100vw, 502px\" \/><\/a><br \/>\n<\/span><br \/>\nDb2batch\u00c2\u00a0can work in both a single partition database and in a multiple partition database, so you don&#8217;t have to worry about the results if the query spans multiple partitions.\u00c2\u00a0<\/p>\n<p><em><br \/>\n<\/em><\/p>\n<p><em><br \/>\n<\/em><\/p>\n<p style=\"text-align: left;\">\u00c2\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have been using db2batch for a while now. The more I use it, the more I like it. It can give you very useful information about your query that can help you tune it. \u00c2\u00a0It can give you execution \/ run time information, run it under certain optimization level, give you explain information, database [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","site-transparent-header":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[3],"tags":[77,943,71,76,75,74,8],"class_list":["post-161","post","type-post","status-publish","format-standard","hentry","category-db2","tag-analyze-sql","tag-db2","tag-db2batch","tag-explain","tag-performance","tag-query","tag-sql"],"_links":{"self":[{"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/posts\/161","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techsatwork.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=161"}],"version-history":[{"count":10,"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/posts\/161\/revisions"}],"predecessor-version":[{"id":1550,"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/posts\/161\/revisions\/1550"}],"wp:attachment":[{"href":"https:\/\/techsatwork.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techsatwork.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=161"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techsatwork.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}