.. _voss_database_commands:

Database Commands
-----------------

.. _19.1.1|EKB-1033:
.. _21.1|VOSS-794|EKB-1173:

.. index:: voss;voss cleardown


.. important::

   On a Modular Architecture deployment, ``voss`` system specific commands
   can only be run on application nodes and for Unified and Single Node architectures, *not* on database or web proxy type nodes.
  



* **voss cleardown** - the command re-initializes the |VOSS Automate| database. It
  is usually run on a fresh installation and care should be taken with its use,
  as it deletes all system data.

  Note that this step may take some time. You can follow the process by
  running **log follow upgrade_db.log** or **log follow voss-deviceapi/app.log**.

.. index:: voss;voss db_collection_stats

* **voss db_collection_stats [ all | <collection,collection,...> ]** - Display detailed statistics of
  all the |VOSS Automate| databases, or of only a list of collections. Mongo database collections are similar
  to tables in relational databases.

  Refer to the example snippets below.


::

   $ voss db_collection_stats


   +--------------------+-----+--------+---------+-------------+------+----------+
   | Collection         | Cnt | % Size | DB Size | AvgObj Size | Idx  | Idx Size |
   +--------------------+-----+--------+---------+-------------+------+----------+
   | VOSS.DATA_ACCESS.. |   8 |   0.0% |  92.88K |      11.61K |    2 |   15.97K |
   | VOSS.DATA_APIVER.. |   1 |   0.0% | 496.00b |     496.00b |    2 |   15.97K |
   | VOSS.DATA_APPLIC.. |   1 |   0.0% |   1.98K |       1.98K |    2 |   15.97K |
   +--------------------+-----+--------+---------+-------------+------+----------+

   ...

   | VOSS.WORKER_QUEUE  |9508 |   9.4% | 117.76M |      12.68K |    9 |    4.34M |
   +--------------------+-----+--------+---------+-------------+------+----------+
   Total Documents: 144624
   Total Data Size: 1.22G
   Total Index Size: 73.31M

::

   $ voss db_collection_stats DATA_RULEMODELHIERARCHYTYPE,SCHEMA
   
   +--------------------+-----+--------+---------+--------------+------+------------+
   | Collection         | Cnt | % Size | DB Size | AvOb Size    | Idx  | Idx Size   |
   +--------------------+-----+--------+---------+--------------+------+------------+
   | VOSS.DATA_RULEMO.. | 318 | 100.0% |  97.61K |   314.00b    |   2  |   96.00K   |
   +--------------------+-----+--------+---------+--------------+------+------------+
   | VOSS.SCHEMA        |  12 |  95.2% |   1.89M |      160.92K |    2 |     72.00K |
   +--------------------+-----+--------+---------+--------------+------+------------+
   Total Documents: 330
   Total Data Size: 1.98M
   Total Index Size: 168.00K


 
.. index:: voss;voss db_index_stats

* **voss db_index_stats** - Display detailed statistics of the |VOSS Automate| database indices, including the
  five largest.

  Refer to the example below.


::  

   $ voss db_index_stats
   
   Index Overview
   +-----------------------+-------------------------------+--------+------------+
   | Collection            | Index                         | % Size | Index Size |
   +-----------------------+-------------------------------+--------+------------+
   | VOSS.DATA_USER        | _id_                          |   0.1% |     44.00K |
   | VOSS.DATA_USER        | username_1___hierarchy_1      |   0.1% |     52.00K |
   | VOSS.RESOURCE         | _id_                          |   0.6% |    460.00K |
   | VOSS.RESOURCE         | _search._i.v_1                |  10.8% |      7.83M |
   | VOSS.RESOURCE         | lock_1                        |   0.3% |    196.00K |

   ...
   

   | VOSS.WORKER_QUEUE     | parent_transaction_id_1_..    |   0.0% |     12.00K |
   +-----------------------+-------------------------------+--------+------------+
   

   Top 5 Largest Indexes
   +----------------------+--------------------------------+--------+------------+
   | Collection           | Index                          | % Size | Index Size |
   +----------------------+--------------------------------+--------+------------+
   | VOSS.RESOURCE        | meta.model_type_1__search._i.. |  16.5% |     11.97M |
   | VOSS.TRANSACTION_LOG | _id_                           |  10.8% |      7.85M |
   | VOSS.RESOURCE        | _search._i.v_1                 |  10.8% |      7.83M |
   | VOSS.TRANSACTION_LOG | _id.t_id_1_time_1              |   8.6% |      6.26M |
   | VOSS.TRANSACTION     | submitted_time_-1_parent_1_a.. |   6.3% |      4.59M |
   +----------------------+--------------------------------+--------+------------+
   
   Total Documents: 743332
   Total Data Size: 2.86G
   Total Index Size: 72.56M

.. index:: voss;voss db_collection_cap_check

* **voss db_collection_cap_check TRANSACTION_LOG** - Returns
  the ``TRANSACTION_LOG`` database collection cap size in GB.


.. index:: voss;voss db_collection_cap


* **voss db_collection_cap TRANSACTION_LOG <10-50GB>** - Updates
  the ``TRANSACTION_LOG`` database collection to a cap size in GB provided as parameter.

  .. important::

     1. The resize operation will impact the usage on the disk size allocated for the
        database (typically, 250GB is reserved upon installation). Consider a larger
        initial disk size allocation if a larger cap size is set.
     2. When resizing a collection, the existing collection is dropped and a new collection
        is created. Transactions in the existing collection can therefore not be re-run.
        
        Therefore, if you resize the transaction log, all existing entries will be
        flushed and are unrecoverable.
     3. The resize operation must be carried out during a maintenance window, since the
        ``voss-deviceapi`` service is restarted during this process.   

  * cap size in GB parameter values:  from 10GB up to 50GB

  This command to change the cap size is to enable larger providers to do this for operational reasons,
  for example for diagnostics and a longer transaction replay window.






.. |VOSS Automate| replace:: VOSS Automate
.. |Unified CM| replace:: Unified CM
