Skip to content

[defect]: PostgreSQL SQL module performance degradation with large datasets and insufficient indexing #5628

@simeononsecurity

Description

@simeononsecurity

What type of defect/bug is this?

Unexpected behaviour (obvious or verified by project member)

How can the issue be reproduced?

How can the issue be reproduced?

  1. Set up FreeRADIUS 3.2.x (Tested in 3.2.3 - 3.2.7) with PostgreSQL backend (tested on versions 16 and 17)
  2. Configure standard radacct, radpostauth, and cui tables using default schema
  3. Generate accounting traffic to accumulate 2+ million records in radacct table
  4. Observe query timeouts and performance degradation
  5. Scale to 10+ million records - performance becomes unacceptable even with buffered/decoupled accounting

High-Level Suggestions for Resolution

Database Schema Issues:

  1. Insufficient Indexing: Default PostgreSQL schema lacks indexes for common WHERE clauses and query patterns used by FreeRADIUS
  2. Monolithic Table Design: radacct, radpostauth, and cui tables grow indefinitely without built-in archival strategy
  3. Partitioning Limitations: Standard partitioning approaches conflict with radacctid uniqueness constraints

Performance Scaling Problems:

  1. Query Timeout Threshold: Performance degrades significantly after ~2 million records without additional indexing
  2. Index Effectiveness Limit: Even with custom indexes, performance issues emerge around 10 million records
  3. Hardware Dependency: Requires NVMe storage and significant hardware upgrades to maintain performance

Architectural Recommendations:

  1. Enhanced Default Indexing: Include performance-optimized indexes in default PostgreSQL schema
  2. Built-in Archival Strategy: Provide recommended data retention and archival procedures
  3. Partitioning Guidance: Document partition-friendly schema modifications for high-volume deployments
  4. Load Distribution: Improve buffered SQL processing with intelligent load balancing
  5. Monitoring Integration: Include performance monitoring recommendations for production deployments

Impact:

This affects any FreeRADIUS deployment using PostgreSQL at scale, particularly ISPs and large organizations processing millions of accounting records. Current workarounds require significant database expertise and custom schema modifications.

Log output from the FreeRADIUS daemon

N/A

Relevant log output from client utilities

N/A

Backtrace from LLDB or GDB

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    defectcategory: a defect or misbehaviour

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions