<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="mysql-cluster-programs-ndb-size-pl">
      </a>
      25.5.29 ndb_size.pl — NDBCLUSTER Size Requirement Estimator
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045095969904">
  </a>
  <p>
   This is a Perl script that can be used to estimate the amount of
        space that would be required by a MySQL database if it were
        converted to use the
   <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
    <code class="literal">
     NDBCLUSTER
    </code>
   </a>
   storage engine. Unlike the other utilities discussed in this
        section, it does not require access to an NDB Cluster (in fact,
        there is no reason for it to do so). However, it does need to
        access the MySQL server on which the database to be tested
        resides.
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    <a class="link" href="mysql-cluster-programs-ndb-size-pl.html" title="25.5.29 ndb_size.pl — NDBCLUSTER Size Requirement Estimator">
     <span class="command">
      <strong>
       ndb_size.pl
      </strong>
     </span>
    </a>
    is deprecated, and no longer
          supported, in NDB 8.4.3 and later. You should expect it to be
          removed from a future version of the NDB Cluster distribution,
          and modify any dependent applications accordingly.
   </p>
  </div>
  <h4>
   <a name="idm46045095964480">
   </a>
   Requirements
  </h4>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      A running MySQL server. The server instance does not have to
            provide support for NDB Cluster.
     </p>
    </li>
    <li class="listitem">
     <p>
      A working installation of Perl.
     </p>
    </li>
    <li class="listitem">
     <p>
      The
      <code class="literal">
       DBI
      </code>
      module, which can be obtained
            from CPAN if it is not already part of your Perl
            installation. (Many Linux and other operating system
            distributions provide their own packages for this library.)
     </p>
    </li>
    <li class="listitem">
     <p>
      A MySQL user account having the necessary privileges. If you
            do not wish to use an existing account, then creating one
            using
      <code class="literal">
       GRANT USAGE ON
       <em class="replaceable">
        <code>
         db_name
        </code>
       </em>
       .*
      </code>
      —where
      <em class="replaceable">
       <code>
        db_name
       </code>
      </em>
      is the name of the
            database to be examined—is sufficient for this
            purpose.
     </p>
    </li>
   </ul>
  </div>
  <p>
   <code class="filename">
    ndb_size.pl
   </code>
   can also be found in the MySQL
        sources in
   <code class="filename">
    storage/ndb/tools
   </code>
   .
  </p>
  <p>
   Options that can be used with
   <a class="link" href="mysql-cluster-programs-ndb-size-pl.html" title="25.5.29 ndb_size.pl — NDBCLUSTER Size Requirement Estimator">
    <span class="command">
     <strong>
      ndb_size.pl
     </strong>
    </span>
   </a>
   are
        shown in the following table. Additional descriptions follow the
        table.
  </p>
  <p>
  </p>
  <h4>
   <a name="idm46045095953072">
   </a>
   Usage
  </h4>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa69576826"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">perl ndb_size<span class="token punctuation">.</span>pl <span class="token punctuation">[</span><span class="token constant">--database</span><span class="token attr-value"><span class="token punctuation">=</span>{<em class="replaceable">db_name</em>|ALL}<span class="token punctuation">]</span></span> <span class="token punctuation">[</span><span class="token constant">--hostname</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">host</em>[:<em class="replaceable">port</em>]<span class="token punctuation">]</span></span> <span class="token punctuation">[</span><span class="token constant">--socket</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">socket</em><span class="token punctuation">]</span></span> \
      <span class="token punctuation">[</span><span class="token constant">--user</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">user</em><span class="token punctuation">]</span></span> <span class="token punctuation">[</span><span class="token constant">--password</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">password</em><span class="token punctuation">]</span></span>  \
      <span class="token punctuation">[</span><span class="token property">--help|-h</span><span class="token punctuation">]</span> <span class="token punctuation">[</span><span class="token constant">--format</span><span class="token attr-value"><span class="token punctuation">=</span>{html|text}<span class="token punctuation">]</span></span> \
      <span class="token punctuation">[</span><span class="token constant">--loadqueries</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">file_name</em><span class="token punctuation">]</span></span> <span class="token punctuation">[</span><span class="token constant">--savequeries</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">file_name</em><span class="token punctuation">]</span></span></code></pre>
  </div>
  <p>
   <a name="option_ndb_size_pl_options">
   </a>
   By default, this utility attempts to analyze all databases on
        the server. You can specify a single database using the
   <code class="option">
    --database
   </code>
   option; the default behavior can be
        made explicit by using
   <code class="literal">
    ALL
   </code>
   for the name of
        the database. You can also exclude one or more databases by
        using the
   <code class="option">
    --excludedbs
   </code>
   option with a
        comma-separated list of the names of the databases to be
        skipped. Similarly, you can cause specific tables to be skipped
        by listing their names, separated by commas, following the
        optional
   <code class="option">
    --excludetables
   </code>
   option. A host name
        can be specified using
   <code class="option">
    --hostname
   </code>
   ; the default
        is
   <code class="literal">
    localhost
   </code>
   . You can specify a port in
        addition to the host using
   <em class="replaceable">
    <code>
     host
    </code>
   </em>
   :
   <em class="replaceable">
    <code>
     port
    </code>
   </em>
   format for the value of
   <code class="option">
    --hostname
   </code>
   . The default
        port number is 3306. If necessary, you can also specify a
        socket; the default is
   <code class="filename">
    /var/lib/mysql.sock
   </code>
   .
        A MySQL user name and password can be specified the
        corresponding options shown. It also possible to control the
        format of the output using the
   <code class="option">
    --format
   </code>
   option;
        this can take either of the values
   <code class="literal">
    html
   </code>
   or
   <code class="literal">
    text
   </code>
   , with
   <code class="literal">
    text
   </code>
   being the
        default. An example of the text output is shown here:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa83617553"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">ndb_size.pl</span> <span class="token constant">--database</span><span class="token attr-value"><span class="token punctuation">=</span>test</span> <span class="token constant">--socket</span><span class="token attr-value"><span class="token punctuation">=</span>/tmp/mysql.sock</span>
ndb_size<span class="token punctuation">.</span>pl report for database<span class="token punctuation">:</span> <span class="token atrule">'test'</span> <span class="token punctuation">(</span>1 tables<span class="token punctuation">)</span>
<span class="token property">--------------------------------------------------</span>
Connected to<span class="token punctuation">:</span> DBI<span class="token punctuation">:</span>mysql<span class="token punctuation">:</span>host<span class="token attr-value"><span class="token punctuation">=</span>localhost;mysql_socket=/tmp/mysql.sock</span>

Including information for versions<span class="token punctuation">:</span> 4<span class="token punctuation">.</span>1<span class="token punctuation">,</span> 5<span class="token punctuation">.</span>0<span class="token punctuation">,</span> 5<span class="token punctuation">.</span>1

test<span class="token punctuation">.</span>t1
<span class="token property">-------</span>

DataMemory for Columns <span class="token punctuation">(</span>* means varsized DataMemory<span class="token punctuation">)</span><span class="token punctuation">:</span>
         Column Name            Type  Varsized   Key  4<span class="token punctuation">.</span>1  5<span class="token punctuation">.</span>0   5<span class="token punctuation">.</span>1
     HIDDEN_NDB_PKEY          bigint             PRI    8    8     8
                  c2     varchar<span class="token punctuation">(</span>50<span class="token punctuation">)</span>         Y         52   52    4*
                  c1         int<span class="token punctuation">(</span>11<span class="token punctuation">)</span>                    4    4     4
                                                       <span class="token property">--</span>   <span class="token property">--</span>    <span class="token property">--</span>
Fixed Size Columns DM/Row                              64   64    12
   Varsize Columns DM/Row                               0    0     4

DataMemory for Indexes<span class="token punctuation">:</span>
   Index Name                 Type        4<span class="token punctuation">.</span>1        5<span class="token punctuation">.</span>0        5<span class="token punctuation">.</span>1
      PRIMARY                BTREE         16         16         16
                                           <span class="token property">--</span>         <span class="token property">--</span>         <span class="token property">--</span>
       Total Index DM/Row                  16         16         16

IndexMemory for Indexes<span class="token punctuation">:</span>
               Index Name        4<span class="token punctuation">.</span>1        5<span class="token punctuation">.</span>0        5<span class="token punctuation">.</span>1
                  PRIMARY         33         16         16
                                  <span class="token property">--</span>         <span class="token property">--</span>         <span class="token property">--</span>
           Indexes IM/Row         33         16         16

Summary <span class="token punctuation">(</span>for THIS table<span class="token punctuation">)</span><span class="token punctuation">:</span>
                                 4<span class="token punctuation">.</span>1        5<span class="token punctuation">.</span>0        5<span class="token punctuation">.</span>1
    Fixed Overhead DM/Row         12         12         16
           NULL Bytes/Row          4          4          4
           DataMemory/Row         96         96         48
                    <span class="token punctuation">(</span>Includes overhead<span class="token punctuation">,</span> bitmap and indexes<span class="token punctuation">)</span>

  Varsize Overhead DM/Row          0          0          8
   Varsize NULL Bytes/Row          0          0          4
       Avg Varside DM/Row          0          0         16

                 No<span class="token punctuation">.</span> Rows          0          0          0

        Rows/32kb DM Page        340        340        680
Fixedsize DataMemory <span class="token punctuation">(</span>KB<span class="token punctuation">)</span>          0          0          0

Rows/32kb Varsize DM Page          0          0       2040
  Varsize DataMemory <span class="token punctuation">(</span>KB<span class="token punctuation">)</span>          0          0          0

         Rows/8kb IM Page        248        512        512
         IndexMemory <span class="token punctuation">(</span>KB<span class="token punctuation">)</span>          0          0          0

Parameter Minimum Requirements
<span class="token property">------------------------------</span>
* indicates greater than default

                Parameter     Default        4<span class="token punctuation">.</span>1         5<span class="token punctuation">.</span>0         5<span class="token punctuation">.</span>1
          DataMemory <span class="token punctuation">(</span>KB<span class="token punctuation">)</span>       81920          0           0           0
       NoOfOrderedIndexes         128          1           1           1
               NoOfTables         128          1           1           1
         IndexMemory <span class="token punctuation">(</span>KB<span class="token punctuation">)</span>       18432          0           0           0
    NoOfUniqueHashIndexes          64          0           0           0
           NoOfAttributes        1000          3           3           3
             NoOfTriggers         768          5           5           5</code></pre>
  </div>
  <p>
   <a name="option_ndb_size_pl_debugging">
   </a>
   For debugging purposes, the Perl arrays containing the queries
        run by this script can be read from the file specified using can
        be saved to a file using
   <code class="option">
    --savequeries
   </code>
   ; a file
        containing such arrays to be read during script execution can be
        specified using
   <code class="option">
    --loadqueries
   </code>
   . Neither of these
        options has a default value.
  </p>
  <p>
   <a name="option_ndb_size_pl_format">
   </a>
   To produce output in HTML format, use the
   <code class="option">
    --format
   </code>
   option and redirect the output to a
        file, as shown here:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa73873101"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">ndb_size.pl</span> <span class="token constant">--database</span><span class="token attr-value"><span class="token punctuation">=</span>test</span> <span class="token constant">--socket</span><span class="token attr-value"><span class="token punctuation">=</span>/tmp/mysql.sock</span> <span class="token constant">--format</span><span class="token attr-value"><span class="token punctuation">=</span>html</span> &gt; ndb_size<span class="token punctuation">.</span>html</code></pre>
  </div>
  <p>
   (Without the redirection, the output is sent to
   <code class="literal">
    stdout
   </code>
   .)
  </p>
  <p>
   The output from this script includes the following information:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Minimum values for the
      <a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-datamemory">
       <code class="literal">
        DataMemory
       </code>
      </a>
      ,
      <a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-indexmemory">
       <code class="literal">
        IndexMemory
       </code>
      </a>
      ,
      <a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnooftables">
       <code class="literal">
        MaxNoOfTables
       </code>
      </a>
      ,
      <a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnoofattributes">
       <code class="literal">
        MaxNoOfAttributes
       </code>
      </a>
      ,
      <a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnooforderedindexes">
       <code class="literal">
        MaxNoOfOrderedIndexes
       </code>
      </a>
      ,
            and
      <a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnooftriggers">
       <code class="literal">
        MaxNoOfTriggers
       </code>
      </a>
      configuration parameters required to accommodate the tables
            analyzed.
     </p>
    </li>
    <li class="listitem">
     <p>
      Memory requirements for all of the tables, attributes,
            ordered indexes, and unique hash indexes defined in the
            database.
     </p>
    </li>
    <li class="listitem">
     <p>
      The
      <a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-indexmemory">
       <code class="literal">
        IndexMemory
       </code>
      </a>
      and
      <a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-datamemory">
       <code class="literal">
        DataMemory
       </code>
      </a>
      required
            per table and table row.
     </p>
    </li>
   </ul>
  </div>
 </div>
 <br/>
</div>
