<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Find table's size in Hive metastore (MySQL) in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Find-table-s-size-in-Hive-metastore-MySQL/m-p/326881#M229959</link>
    <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/72395"&gt;@dr&lt;/a&gt;&amp;nbsp;If it's a managed table, you could get its size from TABLE_PARAMS table:&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SELECT a.TBL_NAME AS `TABLE`, b.PARAM_VALUE AS `SIZE` from TABLE_PARAMS b INNER JOIN TBLS a where a.TBL_ID=b.TBL_ID and b.PARAM_KEY='totalSize';&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could change the you need it. But, if there are external tables, or the table stats are not generated regularly, then you might not get the correct data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could get the table size using HDFS file system commands as well:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;hdfs dfs -du -s -h &amp;lt;path to the table location&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will give you more accurate data.&lt;/P&gt;</description>
    <pubDate>Thu, 07 Oct 2021 17:45:55 GMT</pubDate>
    <dc:creator>smruti</dc:creator>
    <dc:date>2021-10-07T17:45:55Z</dc:date>
    <item>
      <title>Find table's size in Hive metastore (MySQL)</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Find-table-s-size-in-Hive-metastore-MySQL/m-p/325791#M229721</link>
      <description>&lt;P&gt;I have some tables in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;hive&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and I want to find the size of each table through the metastore&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(MySQL).&lt;/P&gt;&lt;P&gt;I am trying the below but it returns paratition_params, notification_log, sds etc. My tables are stored in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;TABLES.TBLS&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;but when I am running the below query with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;from information_schema.TABLES.TBLS&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;it returns this:&lt;/P&gt;&lt;PRE&gt;You have an error &lt;SPAN class="hljs-keyword"&gt;in&lt;/SPAN&gt; your &lt;SPAN class="hljs-keyword"&gt;SQL&lt;/SPAN&gt; syntax; &lt;SPAN class="hljs-keyword"&gt;check&lt;/SPAN&gt; the manual that corresponds &lt;SPAN class="hljs-keyword"&gt;to&lt;/SPAN&gt; your MySQL server version &lt;SPAN class="hljs-keyword"&gt;for&lt;/SPAN&gt; the &lt;SPAN class="hljs-keyword"&gt;right&lt;/SPAN&gt; syntax &lt;SPAN class="hljs-keyword"&gt;to&lt;/SPAN&gt; use near &lt;SPAN class="hljs-string"&gt;'.TBLS

ORDER BY
      (DATA_LENGTH + INDEX_LENGTH)
    DESC
    LIMIT 0, 200'&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;at&lt;/SPAN&gt; line &lt;SPAN class="hljs-number"&gt;5&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;HR /&gt;&lt;PRE&gt;&lt;SPAN class="hljs-keyword"&gt;SELECT&lt;/SPAN&gt;
  TABLE_NAME &lt;SPAN class="hljs-keyword"&gt;AS&lt;/SPAN&gt; `&lt;SPAN class="hljs-keyword"&gt;Table&lt;/SPAN&gt;`,
  ROUND((DATA_LENGTH &lt;SPAN class="hljs-operator"&gt;+&lt;/SPAN&gt; INDEX_LENGTH) &lt;SPAN class="hljs-operator"&gt;/&lt;/SPAN&gt; &lt;SPAN class="hljs-number"&gt;1024&lt;/SPAN&gt; &lt;SPAN class="hljs-operator"&gt;/&lt;/SPAN&gt; &lt;SPAN class="hljs-number"&gt;1024&lt;/SPAN&gt;) &lt;SPAN class="hljs-keyword"&gt;AS&lt;/SPAN&gt; `Size (MB)`
&lt;SPAN class="hljs-keyword"&gt;FROM&lt;/SPAN&gt;
  information_schema.TABLES
&lt;SPAN class="hljs-keyword"&gt;ORDER&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;BY&lt;/SPAN&gt;
  (DATA_LENGTH &lt;SPAN class="hljs-operator"&gt;+&lt;/SPAN&gt; INDEX_LENGTH)
&lt;SPAN class="hljs-keyword"&gt;DESC&lt;/SPAN&gt;;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Sep 2021 07:18:34 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Find-table-s-size-in-Hive-metastore-MySQL/m-p/325791#M229721</guid>
      <dc:creator>drgenious</dc:creator>
      <dc:date>2021-09-30T07:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: Find table's size in Hive metastore (MySQL)</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Find-table-s-size-in-Hive-metastore-MySQL/m-p/326881#M229959</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/72395"&gt;@dr&lt;/a&gt;&amp;nbsp;If it's a managed table, you could get its size from TABLE_PARAMS table:&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SELECT a.TBL_NAME AS `TABLE`, b.PARAM_VALUE AS `SIZE` from TABLE_PARAMS b INNER JOIN TBLS a where a.TBL_ID=b.TBL_ID and b.PARAM_KEY='totalSize';&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could change the you need it. But, if there are external tables, or the table stats are not generated regularly, then you might not get the correct data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could get the table size using HDFS file system commands as well:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;hdfs dfs -du -s -h &amp;lt;path to the table location&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will give you more accurate data.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Oct 2021 17:45:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Find-table-s-size-in-Hive-metastore-MySQL/m-p/326881#M229959</guid>
      <dc:creator>smruti</dc:creator>
      <dc:date>2021-10-07T17:45:55Z</dc:date>
    </item>
  </channel>
</rss>

