Quick Tip: Determining Database “Cell” Count

Posted July 14, 2021 by James Knicely, Vertica Field Chief Technologist

Helpful Tips in blue text with magnifying glass

The Vertica system tables LICENSE_AUDITS and USER_AUDITS include a mysterious column called CELL_COUNT.

What exactly is the Cell Count? It’s simply a calculation that looks like this:

DATABASE CELL_COUNT = (Table_1 Column Count * Table_1 Row Count) + (Table_2 Column Count * Table_2 Row Count) + … + (Table_n Column Count * Table_n Row Count)

Example:

Starting with an empty DB:

verticademos=> \d  
No relations found.

verticademos=> SELECT audit('');
audit
-------
0
(1 row)

verticademos=> SELECT cell_count FROM user_audits ORDER BY audit_start_timestamp DESC LIMIT 1;
cell_count
------------
          0
(1 row)

Let’s create a table with some data:

verticademos=> CREATE TABLE deb (a INT, b VARCHAR);
CREATE TABLE

verticademos=> INSERT INTO deb SELECT randomint(10000000), randomstring(randomint(5)) FROM (SELECT '01-JAN-2018'::TIMESTAMP as tm UNION SELECT '31-DEC-2021'::TIMESTAMP as tm) as t TIMESERIES ts as '1 SECOND' OVER (ORDER BY tm) LIMIT 25000000;
  OUTPUT
----------
25000000
(1 row)

Now let’s audit the DB and check the CELL_COUNT:

verticademos=> SELECT audit('');
   audit
-----------
 222540000
(1 row)

verticademos=> SELECT cell_count FROM user_audits ORDER BY audit_start_timestamp DESC LIMIT 1;
cell_count
------------
   50000000
(1 row)

That’s (25000000 * 2).

Now let’s add another table with the same column count, but with less rows:

verticademos=> CREATE TABLE deb2 LIKE deb;
CREATE TABLE

verticademos=> INSERT INTO deb2 SELECT * FROM deb LIMIT 10000000;
  OUTPUT
----------
10000000
(1 row)

verticademos=> SELECT audit('');
   audit
-----------
 308154000
(1 row)

verticademos=> SELECT cell_count FROM user_audits ORDER BY audit_start_timestamp DESC LIMIT 1;
cell_count
------------
   70000000
(1 row)

That’s (25000000 * 2) + (10000000 * 2).

Have Fun!