{"id":461,"date":"2010-06-10T11:15:38","date_gmt":"2010-06-10T08:15:38","guid":{"rendered":"http:\/\/blog.yavor.info\/?p=461"},"modified":"2012-02-05T11:01:35","modified_gmt":"2012-02-05T11:01:35","slug":"dba_hist_tbspc_space_usage","status":"publish","type":"post","link":"http:\/\/blog.yavor.info\/?p=461","title":{"rendered":"dba_hist_tbspc_space_usage"},"content":{"rendered":"<p>\u041c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u0437\u0430 \u0432\u0441\u0438\u0447\u043a\u0438, \u043a\u043e\u0438\u0442\u043e \u0441\u0438 \u043f\u0430\u0437\u044f\u0442 AWR snapshots \u0437\u0430 \u043f\u043e-\u0434\u044a\u043b\u044a\u0433 \u043f\u0435\u0440\u0438\u043e\u0434 \u043e\u0442 \u0432\u0440\u0435\u043c\u0435. \u041e\u0442 \u0442\u0430\u0437\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043c\u043e\u0436\u0435 \u0434\u0430 \u0441\u0435 \u0438\u0437\u043a\u0430\u0440\u0430 trend \u0437\u0430 \u043d\u0430\u0440\u0430\u0441\u0442\u0432\u0430\u043d\u0435\u0442\u043e \u043d\u0430 \u0431\u0430\u0437\u0430\u0442\u0430. \u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043f\u043e \u043c\u0435\u0441\u0435\u0446\u0438 \u0438\u0437\u0433\u043b\u0435\u0436\u0434\u0430\u0442 \u0442\u0430\u043a\u0430:<\/p>\n<pre class=\"brush:sql\">\r\nselect tsu.snap_id, to_char(sn.mon, 'Mon.YYYY'), round(sum(tsu.tablespace_size * nvl(ts.blocksize, p.value))\/1024\/1024\/1024, 2) GB_size\r\n  from dba_hist_tbspc_space_usage tsu,\r\n       sys.ts$ ts,\r\n       v$parameter p,\r\n       (select trunc(begin_interval_time, 'MONTH') Mon, min(snap_id) snap_id\r\n          from dba_hist_snapshot\r\n         group by trunc(begin_interval_time, 'MONTH')) sn\r\n where p.name = 'db_block_size'\r\n   and tsu.tablespace_id = ts.ts#(+)\r\n   and sn.snap_id = tsu.snap_id\r\n group by tsu.snap_id, sn.mon\r\n order by 1\r\n<\/pre>\n<p>\u0422\u043e\u0437\u0438 SQL \u0438\u0434\u0432\u0430 \u0441 \u043d\u044f\u043a\u043e\u043b\u043a\u043e \u0437\u0430\u0431\u0435\u043b\u0435\u0436\u043a\u0438:<br \/>\n&#8211; \u043c\u0430\u043b\u043a\u043e \u043c\u0438 \u0435 \u0442\u044a\u043f\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043d\u0430 tablespace \u0434\u0430 \u0441\u0435 \u043f\u0430\u0437\u0438 \u0432 \u0431\u043b\u043e\u043a\u043e\u0432\u0435, \u0430 \u043d\u0435 \u0431\u0430\u0439\u0442\u043e\u0432\u0435. \u041e\u0442\u043d\u0435 \u043c\u0438 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0432\u0440\u0435\u043c\u0435 \u0434\u0430 \u0441\u0445\u0432\u0430\u043d\u0430 \u043a\u0430\u043a\u0432\u0438 \u0441\u0430 \u0447\u0438\u0441\u043b\u0430\u0442\u0430. \u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f\u0442\u0430 \u043d\u0435 \u043f\u043e\u043c\u0430\u0433\u0430 \u043c\u043d\u043e\u0433\u043e \ud83d\ude42<br \/>\n&#8211; \u0430\u043a\u043e \u0432 \u043c\u0438\u043d\u0430\u043b\u043e\u0442\u043e \u0435 \u0438\u043c\u0430\u043b\u043e tablespace, \u043a\u043e\u0439\u0442\u043e \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u0435 drop-\u043d\u0430\u0442, \u0441\u0435 \u043f\u0440\u0438\u0435\u043c\u0430, \u0447\u0435 \u0435 \u0431\u0438\u043b \u0441 default-\u043d\u0438\u044f block size. \u0410\u0437, \u043b\u0438\u0447\u043d\u043e \u043d\u0435 \u043d\u0430\u043c\u0435\u0440\u0438\u0445 \u0434\u0440\u0443\u0433 \u043d\u0430\u0447\u0438\u043d<br \/>\n&#8211; \u043e\u0449\u0435 \u043d\u0435\u0449\u043e \u043b\u0435\u043a\u043e \u0442\u044a\u043f\u043e: <code>v$tablespace<\/code> \u043d\u044f\u043c\u0430 \u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u043a\u0430 <code>blocksize<\/code>, \u0434\u043e\u043a\u0430\u0442\u043e <code>dba_tablespaces<\/code> \u043d\u044f\u043c\u0430 <code>ts#<\/code>. \u0417\u0430\u0440\u0430\u0434\u0438 \u0442\u0430\u0437\u0438&#8230; \u0445\u043c&#8230; \u043d\u0435\u043a\u043e\u043d\u0441\u0438\u0441\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442 \u0432 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u0442\u043e, \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0435\u0442\u043e\u0445 \u0434\u0430 \u0438\u0437\u043f\u043e\u043b\u0437\u0432\u0430\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043d\u043e <code>sys.ts$<\/code>. \u041d\u0430 \u043a\u043e\u0439\u0442\u043e \u043d\u0435 \u043c\u0443 \u0445\u0430\u0440\u0435\u0441\u0432\u0430 \u0442\u043e\u0432\u0430, \u043c\u043e\u0436\u0435 \u0434\u0430 \u0441\u0438 \u0433\u0438 join-\u043d\u0435 \u043f\u043e <code>tablespace_name<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u0437\u0430 \u0432\u0441\u0438\u0447\u043a\u0438, \u043a\u043e\u0438\u0442\u043e \u0441\u0438 \u043f\u0430\u0437\u044f\u0442 AWR snapshots \u0437\u0430 \u043f\u043e-\u0434\u044a\u043b\u044a\u0433 \u043f\u0435\u0440\u0438\u043e\u0434 \u043e\u0442 \u0432\u0440\u0435\u043c\u0435. \u041e\u0442 \u0442\u0430\u0437\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043c\u043e\u0436\u0435 \u0434\u0430 \u0441\u0435 \u0438\u0437\u043a\u0430\u0440\u0430 trend \u0437\u0430 \u043d\u0430\u0440\u0430\u0441\u0442\u0432\u0430\u043d\u0435\u0442\u043e \u043d\u0430 \u0431\u0430\u0437\u0430\u0442\u0430. \u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043f\u043e \u043c\u0435\u0441\u0435\u0446\u0438 \u0438\u0437\u0433\u043b\u0435\u0436\u0434\u0430\u0442 \u0442\u0430\u043a\u0430:<\/p>\n<pre lang=\"plsql\">\r\nselect tsu.snap_id, to_char(sn.mon, 'Mon.YYYY'), round(sum(tsu.tablespace_size * nvl(ts.blocksize, p.value))\/1024\/1024\/1024, 2) GB_size<br \/>\r\n  from dba_hist_tbspc_space_usage tsu,<br \/>\r\n       sys.ts$ ts,<br \/>\r\n       v$parameter p,<br \/>\r\n       (select trunc(begin_interval_time, 'MONTH') Mon, min(snap_id) snap_id<br \/>\r\n          from dba_hist_snapshot<br \/>\r\n         group by trunc(begin_interval_time, 'MONTH')) sn<br \/>\r\n where p.name = 'db_block_size'<br \/>\r\n   and tsu.tablespace_id = ts.ts#(+)<br \/>\r\n   and sn.snap_id = tsu.snap_id<br \/>\r\n group by tsu.snap_id, sn.mon<br \/>\r\n order by 1<br \/>\r\n<\/pre>\n<p>\u0422\u043e\u0437\u0438 SQL \u0438\u0434\u0432\u0430 \u0441 \u043d\u044f\u043a\u043e\u043b\u043a\u043e \u0437\u0430\u0431\u0435\u043b\u0435\u0436\u043a\u0438:<br \/>\n&#8211; \u043c\u0430\u043b\u043a\u043e \u043c\u0438 \u0435 \u0442\u044a\u043f\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043d\u0430 tablespace \u0434\u0430 \u0441\u0435 \u043f\u0430\u0437\u0438 \u0432 \u0431\u043b\u043e\u043a\u043e\u0432\u0435, \u0430 \u043d\u0435 \u0431\u0430\u0439\u0442\u043e\u0432\u0435. \u041e\u0442\u043d\u0435 \u043c\u0438 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0432\u0440\u0435\u043c\u0435 \u0434\u0430 \u0441\u0445\u0432\u0430\u043d\u0430 \u043a\u0430\u043a\u0432\u0438 \u0441\u0430 \u0447\u0438\u0441\u043b\u0430\u0442\u0430. \u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f\u0442\u0430 \u043d\u0435 \u043f\u043e\u043c\u0430\u0433\u0430 \u043c\u043d\u043e\u0433\u043e \ud83d\ude42<br \/>\n&#8211; \u0430\u043a\u043e \u0432 \u043c\u0438\u043d\u0430\u043b\u043e\u0442\u043e \u0435 \u0438\u043c\u0430\u043b\u043e tablespace, \u043a\u043e\u0439\u0442\u043e \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u0435 drop-\u043d\u0430\u0442, \u0441\u0435 \u043f\u0440\u0438\u0435\u043c\u0430, \u0447\u0435 \u0435 \u0431\u0438\u043b \u0441 default-\u043d\u0438\u044f block size. \u0410\u0437, \u043b\u0438\u0447\u043d\u043e \u043d\u0435 \u043d\u0430\u043c\u0435\u0440\u0438\u0445 \u0434\u0440\u0443\u0433 \u043d\u0430\u0447\u0438\u043d<br \/>\n&#8211; \u043e\u0449\u0435 \u043d\u0435\u0449\u043e \u043b\u0435\u043a\u043e \u0442\u044a\u043f\u043e: <code>v$tablespace<\/code> \u043d\u044f\u043c\u0430 \u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u043a\u0430 <code>blocksize<\/code>, \u0434\u043e\u043a\u0430\u0442\u043e <code>dba_tablespaces<\/code> \u043d\u044f\u043c\u0430 <code>ts#<\/code>. \u0417\u0430\u0440\u0430\u0434\u0438 \u0442\u0430\u0437\u0438&#8230; \u0445\u043c&#8230; \u043d\u0435\u043a\u043e\u043d\u0441\u0438\u0441\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442 \u0432 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u0442\u043e, \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0435\u0442\u043e\u0445 \u0434\u0430 \u0438\u0437\u043f\u043e\u043b\u0437\u0432\u0430\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043d\u043e <code>sys.ts$<\/code>. \u041d\u0430 \u043a\u043e\u0439\u0442\u043e \u043d\u0435 \u043c\u0443 \u0445\u0430\u0440\u0435\u0441\u0432\u0430 \u0442\u043e\u0432\u0430, \u043c\u043e\u0436\u0435 \u0434\u0430 \u0441\u0438 \u0433\u0438 join-\u043d\u0435 \u043f\u043e <code>tablespace_name<\/code><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/blog.yavor.info\/index.php?rest_route=\/wp\/v2\/posts\/461"}],"collection":[{"href":"http:\/\/blog.yavor.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.yavor.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.yavor.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.yavor.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=461"}],"version-history":[{"count":2,"href":"http:\/\/blog.yavor.info\/index.php?rest_route=\/wp\/v2\/posts\/461\/revisions"}],"predecessor-version":[{"id":724,"href":"http:\/\/blog.yavor.info\/index.php?rest_route=\/wp\/v2\/posts\/461\/revisions\/724"}],"wp:attachment":[{"href":"http:\/\/blog.yavor.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=461"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.yavor.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=461"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.yavor.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}