Database statistics
The bundle comes with a handy stats command that can help you analyze your database state and performance.
All statistics values are tagged using one of the following tags:
info: display global information,read: read statistics,write: write statistics,maint: maintenance statistics, such as PostgreSQL VACUUM,code: occasionally display SQL code, such as CREATE statements.
Per default, all commands will display values using the info and read tags.
In order to display all values, use the --all or -a switch, for example:
vendor/bin/db-tools stats table -aphp bin/console db-tools:stats table -adocker compose run dbtools stats table -aIf you want to specify only a set of tags, you may use the --tag=TAG or -t TAG switch, this option can be specified more than once:
vendor/bin/db-tools stats table -t read -t writephp bin/console db-tools:stats table -t read -t writedocker compose run dbtools stats table -t read -t writeTable statistics
How much size takes a table on your disk? How many rows are they? Does your RDBMS ran analyze, vaccuum or optimize enough?
The vendor/bin/db-tools stats tablephp bin/console db-tools:stats tabledocker compose run dbtools stats table will attempt to give you as many details as possible about table statistics:
- table size on disk,
- table indices size on disk,
- row count,
- sequential read and index read counts (PostgreSQL only),
- index row fetch count (PostgreSQL only),
- maintenance tasks such as
analyzeandvacuumcount and date (PostgreSQL only), - and much more information, whenever the RDBMS allows you to get it.
Simply run:
vendor/bin/db-tools stats tablephp bin/console db-tools:stats tabledocker compose run dbtools stats tableOutput will be ordered by table size in descending order.
Index statistics
This command is PostgreSQL only. It gives information about all your indices size on disk, and a few other pertinent values that may help your debugging performance problems.
Simply run:
vendor/bin/db-tools stats indexphp bin/console db-tools:stats indexdocker compose run dbtools stats indexOutput will be ordered by index size in descending order.
Global statistics
If you run the command without any arguments:
vendor/bin/db-tools statsphp bin/console db-tools:statsdocker compose run dbtools statsdepending upon your current database driver, you might have few or no output.
Global statistics are still being worked out, and what will show up here may greatly vary between RDBMS implementations.