{"id":429,"date":"2024-07-29T20:43:39","date_gmt":"2024-07-29T20:43:39","guid":{"rendered":"https:\/\/humtechno.com\/intro\/?p=429"},"modified":"2024-07-29T20:45:07","modified_gmt":"2024-07-29T20:45:07","slug":"checking-oracle-objects-size","status":"publish","type":"post","link":"https:\/\/humtechno.com\/intro\/2024\/07\/29\/checking-oracle-objects-size\/","title":{"rendered":"Checking Oracle Objects Size"},"content":{"rendered":"\n\n\n\n<p>Checking the size of objects in an Oracle Database can be done using built-in dictionary views. These views provide information on how much space different database objects like tables and indexes are using. By querying these views, you can easily see the storage size of each object. This helps you manage your database storage more effectively and ensures that your database remains efficient. Using these views regularly can help you keep track of and optimize your database&#8217;s performance.<\/p>\n\n<p><strong>Tablespace Size Query<\/strong><\/p>\n\n<p>SELECT ts.tablespace_name,<br>size_info.megs_alloc,<br>size_info.megs_free\/1024,<br>size_info.megs_used,<br>size_info.pct_free,<br>size_info.pct_used,<br>size_info.MAX,<br>size_info.Available \/1024 Available_GB,<br>Available_Percentage<br>FROM (SELECT a.tablespace_name,<br>ROUND (a.bytes_alloc \/ 1024 \/ 1024) megs_alloc,<br>ROUND (NVL (b.bytes_free, 0) \/ 1024 \/ 1024) megs_free,<br>ROUND ( (a.bytes_alloc &#8211; NVL (b.bytes_free, 0)) \/ 1024 \/ 1024)<br>megs_used,<br>ROUND ( (NVL (b.bytes_free, 0) \/ a.bytes_alloc) * 100)<br>Pct_Free,<br>100 &#8211; ROUND ( (NVL (b.bytes_free, 0) \/ a.bytes_alloc) * 100)<br>Pct_used,<br>ROUND (maxbytes \/ 1048576) MAX,<br>((ROUND (maxbytes \/ 1048576))- (ROUND ( (a.bytes_alloc &#8211; NVL (b.bytes_free, 0)) \/ 1024 \/ 1024))) as Available<br>, (((ROUND (maxbytes \/ 1048576))- (ROUND ( (a.bytes_alloc &#8211; NVL (b.bytes_free, 0)) \/ 1024 \/ 1024))) \/(ROUND (maxbytes \/ 1048576)))*100 as Available_Percentage<br>FROM ( SELECT f.tablespace_name,<br>SUM (f.bytes) bytes_alloc,<br>SUM (<br>DECODE (f.autoextensible,<br>&#8216;YES&#8217;, f.maxbytes,<br>&#8216;NO&#8217;, f.bytes))<br>maxbytes<br>FROM dba_data_files f<br>GROUP BY tablespace_name) a,<br>( SELECT f.tablespace_name, SUM (f.bytes) bytes_free<br>FROM dba_free_space f<br>GROUP BY tablespace_name) b<br>WHERE a.tablespace_name = b.tablespace_name(+)<br>UNION ALL<br>SELECT h.tablespace_name,<br>ROUND (SUM (h.bytes_free + h.bytes_used) \/ 1048576) megs_alloc,<br>ROUND (<br>SUM (<br>(h.bytes_free + h.bytes_used) &#8211; NVL (p.bytes_used, 0))<br>\/ 1048576)<br>megs_free,<br>ROUND (SUM (NVL (p.bytes_used, 0)) \/ 1048576) megs_used,<br>ROUND (<br>( SUM (<br>(h.bytes_free + h.bytes_used)<br>&#8211; NVL (p.bytes_used, 0))<br>\/ SUM (h.bytes_used + h.bytes_free))<br>* 100)<br>Pct_Free,<br>100<br>&#8211; ROUND (<br>( SUM (<br>(h.bytes_free + h.bytes_used)<br>&#8211; NVL (p.bytes_used, 0))<br>\/ SUM (h.bytes_used + h.bytes_free))<br>* 100)<br>pct_used,<br>ROUND (<br>SUM (<br>DECODE (f.autoextensible,<br>&#8216;YES&#8217;, f.maxbytes,<br>&#8216;NO&#8217;, f.bytes)<br>\/ 1048576))<br>MAX,<br>(((ROUND (SUM (DECODE (f.autoextensible,&#8217;YES&#8217;, f.maxbytes,&#8217;NO&#8217;, f.bytes) \/ 1048576))) -(ROUND (SUM (NVL (p.bytes_used, 0)) \/ 1048576)))\/1024) as Available_GB<br>,((((ROUND (SUM (DECODE (f.autoextensible,&#8217;YES&#8217;, f.maxbytes,&#8217;NO&#8217;, f.bytes) \/ 1048576))) -(ROUND (SUM (NVL (p.bytes_used, 0)) \/ 1048576)))) \/(ROUND (SUM (DECODE (f.autoextensible,&#8217;YES&#8217;, f.maxbytes,&#8217;NO&#8217;, f.bytes) \/ 1048576)))) * 100 as Available_Percentage<br>FROM sys.v_$TEMP_SPACE_HEADER h,<br>sys.v_$Temp_extent_pool p,<br>dba_temp_files f<br>WHERE p.file_id(+) = h.file_id<br>AND p.tablespace_name(+) = h.tablespace_name<br>AND f.file_id = h.file_id<br>AND f.tablespace_name = h.tablespace_name<br>GROUP BY h.tablespace_name) size_info,<br>sys.dba_tablespaces ts,<br>sys.dba_tablespace_groups tsg<br>WHERE ts.tablespace_name = size_info.tablespace_name<br>AND ts.tablespace_name = tsg.tablespace_name(+)<br>order by Available_Percentage asc;<\/p>\n\n<p><strong>Check Tables Size<\/strong><\/p>\n\n<p>SELECT (SELECT SYSDATE FROM DUAL) AS dbdate,<br>(SELECT NAME FROM v$database) AS database_name,<br>&#8221; AS tablespace_name,<br>owner,<br>table_name,<br>SUM (BYTES) AS total,<br>0 AS free,<br>0 AS used,<br>0 AS maxbytes,<br>(SELECT num_rows<br>FROM dba_tables a<br>WHERE a.owner = ss.owner AND a.table_name = ss.table_name)<br>AS rowscount<br>FROM (SELECT segment_name table_name, owner, BYTES<br>FROM dba_segments<br>WHERE segment_type IN<br>(&#8216;TABLE&#8217;, &#8216;TABLE PARTITION&#8217;, &#8216;TABLE SUBPARTITION&#8217;)<br>UNION ALL<br>SELECT i.table_name, i.owner, s.BYTES<br>FROM dba_indexes i,<br>dba_segments s<br>WHERE s.segment_name = i.index_name<br>AND s.owner = i.owner<br>AND s.segment_type IN<br>(&#8216;INDEX&#8217;, &#8216;INDEX PARTITION&#8217;, &#8216;INDEX SUBPARTITION&#8217;)<br>UNION ALL<br>SELECT l.table_name, l.owner, s.BYTES<br>FROM dba_lobs l,<br>dba_segments s<br>WHERE s.segment_name = l.segment_name<br>AND s.owner = l.owner<br>AND s.segment_type IN (&#8216;LOBSEGMENT&#8217;, &#8216;LOB PARTITION&#8217;)<br>UNION ALL<br>SELECT l.table_name, l.owner, s.BYTES<br>FROM dba_lobs l,<br>dba_segments s<br>WHERE s.segment_name = l.index_name<br>AND s.owner = l.owner<br>AND s.segment_type = &#8216;LOBINDEX&#8217;) ss<br>where owner=&#8217;CISADM&#8217;<br>GROUP BY table_name,owner<br>order by table_name<br>;<\/p>\n\n<p><strong>Check Recover Area Size<\/strong><\/p>\n\n<p>select name, floor(space_limit \/ 1024 \/ 1024\/1024) &#8220;Size GB&#8221;, ceil(space_used \/ 1024 \/ 1024\/1024) &#8220;Used GB&#8221; from v$recovery_file_dest order by name;<\/p>\n\n<p><strong>Archive log Size During some Period<\/strong><\/p>\n\n<p>select trunc(first_time),count(<em>),sum(blocks<\/em>block_size)\/1024\/1024\/1024 from V$ARCHIVED_LOG<br>where first_time &gt; sysdate -4 group by trunc(first_time) order by trunc(first_time) ;<\/p>\n\n<p><\/p>\n\n\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":2,"featured_media":333,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"pagelayer_contact_templates":[],"_pagelayer_content":"","footnotes":""},"categories":[3],"tags":[51,50,47,52,48,49],"class_list":["post-429","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oracle","tag-flashback-area-size","tag-index-size","tag-oracle-database-object-size","tag-recovery-area-size","tag-tables-size","tag-tablespace-size"],"_links":{"self":[{"href":"https:\/\/humtechno.com\/intro\/wp-json\/wp\/v2\/posts\/429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/humtechno.com\/intro\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/humtechno.com\/intro\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/humtechno.com\/intro\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/humtechno.com\/intro\/wp-json\/wp\/v2\/comments?post=429"}],"version-history":[{"count":2,"href":"https:\/\/humtechno.com\/intro\/wp-json\/wp\/v2\/posts\/429\/revisions"}],"predecessor-version":[{"id":431,"href":"https:\/\/humtechno.com\/intro\/wp-json\/wp\/v2\/posts\/429\/revisions\/431"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/humtechno.com\/intro\/wp-json\/wp\/v2\/media\/333"}],"wp:attachment":[{"href":"https:\/\/humtechno.com\/intro\/wp-json\/wp\/v2\/media?parent=429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/humtechno.com\/intro\/wp-json\/wp\/v2\/categories?post=429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/humtechno.com\/intro\/wp-json\/wp\/v2\/tags?post=429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}