# Postgres Auditing in 150 lines of SQL

DevFeed: [Postgres Auditing in 150 lines of SQL](<https://devfeed.tech/articles/postgres-auditing-in-150-lines-of-sql-495.md>)

Original publisher: [Read original article](<https://supabase.com/blog/postgres-audit>)

Author: Oliver Rice

Published: 2022-03-08T07:00:00Z

Content type: article

Language: en

Sources: [Supabase Blog](<https://devfeed.tech/sources/supabase-blog.md>)

Topics: [PostgreSQL](<https://devfeed.tech/topics/postgresql.md>), [SQL](<https://devfeed.tech/topics/sql.md>), [Databases](<https://devfeed.tech/topics/databases.md>)

Tags: [audit](<https://devfeed.tech/tags/audit.md>), [index](<https://devfeed.tech/tags/index.md>), [postgres](<https://devfeed.tech/tags/postgres.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [schema](<https://devfeed.tech/tags/schema.md>), [sql](<https://devfeed.tech/tags/sql.md>)

## AI overview

This article presents a generic PostgreSQL auditing solution implemented in 150 lines of SQL. It explains how to track table changes over time, store audit records across multiple tables, preserve schema flexibility, maintain compatibility across PostgreSQL versions, and support efficient time-range queries with indexing.

## Source excerpt

PostgreSQL has a robust set of features which we can leverage to create a generic auditing solution in 150 lines of SQL.