PostgreSQL: How to show database size
Related cards:
PostgreSQL: How to show table sizes
When you have a large PG database, you may want to find out which tables are consuming the most disk space.
You can easily check this using the following SQL statement from the PostgreSQL wiki.
SELECT nspname || '.' || relname AS "relation",
...
PostgreSQL: Show size of all databases
Use this:
SELECT pg_database.datname as "database_name", pg_database_size(pg_database.datname)/1024/1024 AS size_in_mb FROM pg_database ORDER by size_in_mb DESC;
Want to see [database sizes in MySQL](https://makandracards.com/makandra/1447-...
Customize tokenization of the MySQL FULLTEXT parser
The way MySQL's FULLTEXT tokenizer splits text into word tokens might not always be what you need. E.g. it splits a word at period characters.
Since the tokenizer has near-zero configuration options (minimum word length and stopwords list), you n...
Invoices: How to properly round and calculate totals
While it might seem trivial to implement an invoice that sums up items and shows net, gross and vat totals, it actually involves a lot of rules and caveats. It is very easy to create invoices where numbers don't add up and a few cents are missing....
Use DatabaseCleaner with multiple test databases
There is a way to use multiple databases in Rails.
You may have asked yourself how you're able to keep your test databases clean, if you're running multiple databases with ful...
How to make Rational#to_s return strings without denominator 1 again
The way Rational#to_s
works on Ruby has changed from Ruby 1.9 on. Here is how to get the old behavior back.
You may want this for things where Rationals are being used, like when subtracting Date
objects from one another.
What's happening?...
PostgreSQL: How to add/remove/modify array values (and how to replace 1 value with multiple values)
PostgreSQL's array data type is pretty useful, but manipulating values of arrays can be awkward because of its syntax.
Consider the following users
table which each example below will sta...
How to: Specify size of Selenium browser window
Applications often show or hide elements based on viewport dimensions, or may have components that behave differently (like mobile vs desktop navigation menus).
Since you want your integration tests to behave consistently, you want to set a specif...
List sizes of MySQL databases
Do you wonder which databases are actually taking up how much space but only have one huge ibdata1
in your /var/lib/mysql
and the directories inside your mysql data directory don't represent the actual database sizes? This is for you!
Run fro...
PostgreSQL vs. Rails migration: How to change columns from string to integer
When writing Rails migrations to convert a string
column to an integer
you'd usually say:
change_column :table_name, :column_name, :integer
However, PostgreSQL will complain:
PG::DatatypeMismatch: ERROR: column "column_name" cannot...