Liquibase Enterprise was formerly known as Datical DB.

Settings for Collecting Row Counts

Overview

When building the in memory model of the current database state used to evaluate and simulate pending changes, Datical collects row counts from each table. In environments with many tables or with tables that have many rows this operation can become time consuming. As of release 5.7, the collection of row counts changed from a boolean (true | false) to multiple values (exact, approximate, disabled).  In older projects, true is mapped to exact and false is mapped to disabled.  Using approximate is typically faster than using exact (true).


Note

The default setting starting in v5.7 has changed to disabled (false). 

Managing the Project Setting for Row Count Collection

The project setting can be managed in any of the following ways:

  • GUI: In the project, click the Settings tab. The option is in the Deployment Settings section under Forecast/Deploy: Collect row counts for all tables during Forecast (if needed for rules).
  • CLI: you can set and show the enableRowCount setting
  • Datical Service: the setting is in the Project Settings in the Deployment tab. 

The setting is one of the following values. It is disabled by default. 

  • exact - Use a table scan to count the rows (uses the most time)
  • approximate - Use statistics to provide an approximate value (uses less time)
  • disabled - Do not collect row counts

Database Statistics Used for Approximating Row Counts

The availability and accuracy of table statistics depends on how often you collect and store the statistics on the database server.  These details are only for when you set enableRowCount="approximate":

DatabasePrerequisiteHow Value is ObtainedSee Also 
Oracle

Run DBMS_STATS.GATHER_TABLE_STATS to collect or update the statistics.

Permissions

Requires DBA privilege. 

Source

Value in dba_tables.num_rows for each table.

Sample Query

SELECT CONCAT(OWNER,CONCAT('.', TABLE_NAME)) as TABLE_NAME, NUM_ROWS FROM DBA_TABLES WHERE OWNER IN ('&USER_NAME');
Oracle Database Tips
SQL ServerNone. Statistics are kept automatically.

Permissions

Source

Uses a sum of row_counts from sys.dm_db_partition_stats to get the total number of rows in the heap or clustered index on the table.

Sample Query 

SELECT (OBJECT_SCHEMA_NAME(object_id)+ '.' + OBJECT_NAME(object_id)) as TABLE_NAME, 
CAST(row_count AS float) as NUM_ROWS FROM sys.dm_db_partition_stats
where OBJECT_SCHEMA_NAME(object_id) IN ('DAT28');
MSDN Blog
DB2Run RUNSTATS to collect or update the statistics. 

Permissions

The following roles have the necessary permission:

  • ACCESSCTRL
  • DATAACCESS
  • DBADM
  • SECADM
  • SQLADM
  • SYSADM
  • SYSCTRL
  • SYSMAINT
  • SYSMON

Source

Uses syscat.tables view. 

Sample Query

SELECT CONCAT(TRIM(TABSCHEMA), CONCAT('.', TABNAME)) as TABLE_NAME, SUM(CARD) AS NUM_ROWS
FROM syscat.tables WHERE TABSCHEMA not in ('SYSIBM', 'SYSPUBLIC', 'SYSCAT', 'SYSSTAT', 'SYSIBMADM', 'SYSTOOLS')
and TABSCHEMA in ('db2intuser') GROUP BY TABSCHEMA, TABNAME;
TOOLBOX
EDB PostgresPerform an ANALYZE before forecast or deploy to get the most accurate values.

Permissions

No special permissions required. 

Source

Uses statistics from the catalog table pg_class

Sample Query

SELECT concat(relnamespace::regnamespace::text,'.',pgc.relname) as TABLE_NAME, pgc.reltuples::BIGINT AS NUM_ROWS 
FROM pg_class pgc WHERE pgc.relkind='r' and relnamespace::regnamespace::text not in ('pg_catalog', 'information_schema', 'sys', 'public', 'pgagent')
and relnamespace::regnamespace::text IN ('SchemaNameHere');
PostgreSQL wiki

Overriding the Row Count Setting in Forecast and Deploy Operations

You can override the project settings when you perform a forecast or deploy operation. 

  • GUI - Set a different value for the option in the Forecast and Deploy wizards. 
  • CLI - Provide a different value in the enableRowCount option for the forecast and deploy commands.


Copyright © Liquibase 2012-2022 - Proprietary and Confidential