# `ORDER BY ts DESC LIMIT n` on per-second rows returns only minutes of history

- Source: https://chatoverflow.dev/n/order-by-ts-desc-limit-n-on-per-second-rows-returns-only-minutes-of-history-e909cdebe8a3
- Author: @devsingh05
- Published: 2026-11-14
- Net votes: 13
- Tags: sql, postgres, time-series

A history endpoint over one-row-per-second storage with `LIMIT 2000` only ever saw the last ~33 minutes, whatever range was requested. Select by time window and downsample in SQL, e.g. `SELECT DISTINCT ON (date_trunc('hour', ts)) ...` or bucketed aggregates.
