published by whitemice on Mon, 10/21/2019 - 09:36
In some effort to avoid time-zone drama, or perhaps due to fantasies of efficiency, some developer put a date-time field in a PostgreSQL database as an integer; specifically as a UNIX Time value. ¯\_(ツ)_/¯
How to present this as a normal date in a query result?
published by whitemice on Wed, 09/11/2019 - 11:09
Dates in databases are a tedious thing. Sometimes a time value is recorded as a timestamp, at other times - probably in most cases - it is recorded as a date. Yet it can be useful to perform date-time queries using a representation of time distinct from what is recorded in the table. For example a database which records timestamps, but I want to look-up records by date.
To this end PostgreSQL supports indexing a table by a cast of a field.
published by whitemice on Sat, 03/10/2018 - 20:15
Upgrading a database is always a tedious process - a responsible administrator will have to read through the Changelog for every subsequent version from the version ze is upgrading from to the one ze is upgrading to.
Then I found this! This is a Changelog viewer which allows you to select a from and a to version and shows you all the changelogs in between; on one page. You still have to read it, of course, but this is a great time saver.
published by whitemice on Thu, 02/09/2017 - 06:43
Distribution: CentOS 6.x / RHEL 6.x
If you already have a current version of PostgreSQL server installed on your server from the PGDG repository you should skip these first two steps.
published by whitemice on Mon, 11/18/2013 - 00:00
A powerful feature of PostgreSQL is the ability to create table spaces and to move database objects between them. Each table space represents a physical storage location; so using table spaces you can tier data onto different grades of storage [SSD vs. fast disk vs. slow disk] as well as move data from storage being retired [like an iSCSI SAN] to a new storage [a Fiber-Channel SAN!].
published by whitemice on Wed, 01/09/2013 - 00:00
One of the key steps for performing tuning a database is to test indexing strategies and their effect on performance. It is a series of:
- Drop the indexes
- Create new indexes
- Update statistics
- EXPLAIN the important queries.
Rinse and repeat.
published by whitemice on Mon, 02/06/2012 - 13:06
In recent versions of PostgreSQL there is a magical view called pg_stat_user_tables which provides per table information on usage; there is one row per table and eight counters per row.
Fields