Skip to content

Support for PostgreSQL partitioned tables #780

@samiashi

Description

@samiashi

Summary

It would be useful if django-auditlog could optionally create or use a PostgreSQL partitioned table for its LogEntry model.
This would allow large audit logs to scale more efficiently by leveraging native partitioning.


Current Behavior

Currently, LogEntry is created as a single monolithic table via Django migrations.
All audit entries are written to that table through the ORM.
This design works fine for small and medium volumes, but when audit data grows into tens or hundreds of millions of rows, retention and query performance degrade significantly.

Django itself can work with partitioned tables transparently (when the parent table handles inserts), but django-auditlog doesn’t provide a clean way to:

  • create the LogEntry table as partitioned,
  • manage partitions (by date, etc.), or
  • configure a custom table for the LogEntry model.

Desired Behavior

Provide an option or documented pattern to allow:

  1. Automatic or manual creation of partitions (daily, monthly, etc.).
  2. A Django setting or model option to specify:
AUDITLOG_PARTITION_BY = 'timestamp'
AUDITLOG_PARTITION_INTERVAL = 'month'

This would let large installations keep audit data long-term while maintaining manageable table sizes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions