Historical Queries

Vertica supports querying historical data for individual SELECT statements.

Syntax

Vertica can run a query from a backup of the database taken at a specific date and time or at a specific epoch. The syntax is:

   AT TIME 'timestamp' select...
   AT EPOCH epoch_number select...
   AT EPOCH LATEST select...

The command queries all data in the database up to and including the specified epoch or the epoch representing the specified date and time, without holding a lock or blocking write operations. The specified TIMESTAMP and epoch_number values must be greater than or equal to the Ancient History Mark epoch.

Parameters

AT EPOCH LATEST

Queries all committed data in the database up to, but not including, the current epoch.

AT EPOCH epoch_number

Queries all data in the database up to and including the specified epoch without holding a lock or blocking write operations.

AT TIME 'timestamp'

Queries all committed data in the database up to the time stamp specified. AT TIME 'timestamp' queries are resolved to the next epoch boundary before being evaluated.

Historical queries are useful because they access data in past epochs only. Historical queries do not need to hold table locks or block write operations because they do not return the absolute latest data. Their content is private to the transaction and valid only for the length of the transaction.

Historical queries behave in the same manner regardless of transaction isolation level. Historical queries observe only committed data, even excluding updates made by the current transaction, unless those updates are to a temporary table.

Be aware that there is only one backup of the logical schema. This means that any changes you make to the schema are reflected across all epochs. If, for example, you add a new column to a table and you specify a default value for the column, all historical epochs display the new column and its default value.