# How to check table freshness without a timestamp column (BigQuery, Snowflake, Postgres)

> BigQuery and Snowflake record when a table last changed. Postgres does not, so you add a load timestamp, turn on commit timestamps, or watch write counters.

Source: https://rowmonitor.com/guides/freshness-without-timestamp-column · Updated 2026-11-17

BigQuery and Snowflake both record when a table last changed, so you can check freshness from metadata without a timestamp column. Postgres does not store a last-modified time for a table. There you either add a load timestamp, turn on commit timestamps, or watch write counters between checks.

The Postgres statements below were run on Postgres 15, 16, and 17. The SQL is the same on all three. The BigQuery and Snowflake queries were checked against those products' documentation and were not executed.

## BigQuery: storage_last_modified_time

`INFORMATION_SCHEMA.TABLE_STORAGE` has `storage_last_modified_time`, documented as the most recent time data was written to the table. It is null when the table has no data, and then `hours_since_write` is null too.

```sql
SELECT
  table_schema,
  table_name,
  storage_last_modified_time,
  TIMESTAMP_DIFF(CURRENT_TIMESTAMP(), storage_last_modified_time, HOUR) AS hours_since_write
FROM `region-us`.INFORMATION_SCHEMA.TABLE_STORAGE
WHERE table_schema = 'analytics'
  AND table_name = 'orders';
```

- The query needs a region qualifier (`region-us`, `region-eu`, and so on) that matches the dataset. BigQuery's docs say the query region and the view's region have to match. `region-us` above is an example, not a region this query was run in.
- The documented permissions are `bigquery.tables.get` and `bigquery.tables.list`. The BigQuery Metadata Viewer role includes both.
- The view is not real time. The docs say updates are usually delayed by a few seconds to a few minutes, so don't alert on a lag shorter than that. Storage changes caused only by partition or table expiration, or by a change to the dataset time-travel window, can take up to a day to show up.
- If the error says the view has not been enabled for the project, the docs show ALTER PROJECT or ALTER ORGANIZATION setting `region-<region>.enable_info_schema_storage` to true. They say to allow about a day after that for the full history.

## Snowflake: LAST_ALTERED (and why it can lie)

```sql
SELECT
  table_name,
  last_altered,
  last_ddl,
  row_count,
  DATEDIFF('hour', last_altered, CURRENT_TIMESTAMP()) AS hours_since_change
FROM analytics_db.INFORMATION_SCHEMA.TABLES
WHERE table_schema = 'PUBLIC'
  AND table_name = 'ORDERS';
```

This was not run on Snowflake. The columns and the notes below are from the `INFORMATION_SCHEMA.TABLES` docs. Unquoted identifiers are stored in uppercase, so `PUBLIC` and `ORDERS` match a table created as `orders`. `LAST_ALTERED` and `LAST_DDL` are `TIMESTAMP_LTZ`. `DATEDIFF` counts from `last_altered` to `CURRENT_TIMESTAMP()`.

Read the usage notes before you trust `LAST_ALTERED`. The docs say it changes on DDL, on DML even when no rows are affected, and on Snowflake's own background metadata maintenance. A recent `LAST_ALTERED` means the table was touched. It does not prove new rows arrived. For DML, the value is the time the statement started, not when it committed.

- Store `row_count` with each check and alert when `last_altered` moves but `row_count` does not change for longer than usual. The docs describe `ROW_COUNT` as the number of rows. They do not say how quickly it updates, and this query was not run, so don't treat it as a live count.
- `LAST_DDL` moves on DDL (create, alter, drop, and column changes). A newer `LAST_ALTERED` can still be a DML statement that changed no rows, or background maintenance, so `LAST_DDL` separates structure changes from those other touches. It does not by itself prove that new rows arrived.
- For an external table, `LAST_ALTERED` is not necessarily the last refresh. The docs point to `SYSTEM$EXTERNAL_TABLE_PIPE_STATUS` for the last file Snowflake registered.

## Postgres: three options

Postgres keeps no per-table last-modified time. The three statements below behaved the same on Postgres 15, 16, and 17.

### 1. Add a load timestamp

This is the best option if you own the table. On a table that already had rows, `ADD COLUMN loaded_at timestamptz NOT NULL DEFAULT now()` stamped every existing row with the time of the `ALTER`. The first `max(loaded_at)` was that same instant, so the table looked fresh. An `UPDATE` of `amount` left `loaded_at` unchanged. A later `INSERT` set `loaded_at` to the insert time, and `max(loaded_at)` followed it.

```sql
ALTER TABLE orders ADD COLUMN loaded_at timestamptz NOT NULL DEFAULT now();

SELECT now() - max(loaded_at) AS lag FROM orders;
```

The default only covers inserts. If rows are updated in place, set `loaded_at` in the loader or with a trigger. Add an index on `loaded_at` if the table is big. The [Postgres data quality guide](https://rowmonitor.com/guides/postgres-data-quality-checks) uses the same `max(timestamp)` pattern.

### 2. Commit timestamps

No schema change, but the setting takes effect only at server start. With `track_commit_timestamp` off, this query failed on 15, 16, and 17 with `could not get commit timestamp data` and a hint to set `track_commit_timestamp`. That is configuration, not a version difference in the SQL.

```sql
-- postgresql.conf: track_commit_timestamp = on
-- takes effect only after a server restart

SELECT max(pg_xact_commit_timestamp(xmin)) AS last_write_commit FROM orders;
```

After turning the setting on and restarting Postgres 17, rows committed earlier came back with a null timestamp. A new insert had a commit timestamp, and `max(pg_xact_commit_timestamp(xmin))` returned that time. The docs also say commit-timestamp information is routinely removed during vacuum. This test did not run a vacuum that removed any, so that limit is from the docs. The function scans the table, so keep it for small or medium tables.

### 3. Write counters between checks

Cheap, and no schema change on the data table. `pg_stat_user_tables` keeps cumulative `n_tup_ins`, `n_tup_upd`, and `n_tup_del`.

```sql
CREATE TABLE IF NOT EXISTS freshness_snapshot (
  relname text,
  taken_at timestamptz DEFAULT now(),
  writes bigint
);

WITH cur AS (
  SELECT relname, n_tup_ins + n_tup_upd + n_tup_del AS writes
  FROM pg_stat_user_tables
  WHERE relname = 'orders'
),
prev AS (
  SELECT DISTINCT ON (relname) relname, writes, taken_at
  FROM freshness_snapshot
  ORDER BY relname, taken_at DESC
)
SELECT cur.relname,
       cur.writes - prev.writes AS writes_since_last_check,
       prev.taken_at
FROM cur
LEFT JOIN prev USING (relname);

INSERT INTO freshness_snapshot (relname, writes)
SELECT relname, n_tup_ins + n_tup_upd + n_tup_del
FROM pg_stat_user_tables
WHERE relname = 'orders';
```

On the first run, before any snapshot row existed, `writes_since_last_check` was null, not zero. Right after an insert in the same session, `pg_stat_user_tables` still showed the previous total. A new session a second later showed the new insert. Read the counters on a later check, not in the same breath as the load. Zero writes over a window where you expected a load means the table is stale. `pg_stat_reset()` sent the counters back to zero, and the next difference was negative (0 minus the saved total). A negative difference means the stats were reset, not that rows disappeared.

## Where Row Monitor fits

Row Monitor checks freshness, schema, and row counts on the tables you name, once a day. On BigQuery, freshness is the table's last-modified metadata. On Snowflake, it is `LAST_ALTERED`. On Postgres, it is the latest value of a timestamp column you choose, or one it detects (`updated_at`, then `created_at`, then any timestamp). If a Postgres table has no reliable timestamp, choose "Do not check freshness" for that monitor. Schema and row-count checks still run. Prices are in US dollars.

If Airflow loads the table, the Airflow plugin (Beta) reports run metadata and a heartbeat of unpaused schedules. Airflow checks run about every 15 minutes and can flag a failed run, a late run, or a missed run. The plugin does not emit a never-started event. A missed run is inferred from the schedule on the heartbeat. Free covers 3 tables and 5 DAGs at US$0. Rebuilding a bad day without duplicating rows is covered in [backfill without duplicates](https://rowmonitor.com/posts/backfill-without-duplicates). Install steps are on the [Airflow page](https://rowmonitor.com/airflow).

## Freshness without a timestamp column

Row Monitor checks the tables you name once a day. BigQuery freshness uses last-modified metadata. Snowflake freshness uses `LAST_ALTERED`. Postgres freshness uses a timestamp column, and you can turn that check off when the table has none. Airflow checks run about every 15 minutes. Free is US$0 for 3 tables.

[Start free](https://rowmonitor.com/signup)

## FAQ

### How do I find when a BigQuery table was last updated?

Query storage_last_modified_time in region-<region>.INFORMATION_SCHEMA.TABLE_STORAGE. The docs say the view usually lags by a few seconds to a few minutes, and that the column is null when the table has no data. This query was not run here.

### Does Snowflake LAST_ALTERED mean new data arrived?

Not always. The TABLES view docs say it also changes on DDL, on DML that affects no rows, and on background metadata maintenance. For DML, the timestamp is when the statement started, not when it committed. Pair it with a row-count change. This query was not run here.

### Does Postgres store a table's last modified time?

No. Add a load timestamp, enable track_commit_timestamp and restart the server, or diff pg_stat_user_tables write counters between checks. With the setting off, pg_xact_commit_timestamp fails with could not get commit timestamp data on Postgres 15, 16, and 17.

### Can I monitor a Postgres table that has no timestamp column?

Yes. Use write counters, or a row-count check. In Row Monitor, choose Do not check freshness for that monitor. Schema and row-count checks still run. Table checks run once a day.
