brandon 4a20e545dd feat: optimize vulnerabilities API with PostgreSQL indexes and true backend pagination
Database Optimizations:
- Add composite indexes on (cveId, severity, cvssScore) for efficient aggregation
- Add GIN trigram indexes on cveId, packageName, description, title for fast ILIKE searches
- Add index on (cveId, scanId) for efficient COUNT DISTINCT operations
- Enable pg_trgm extension for trigram matching

Query Improvements:
- Rewrite query to use GROUP BY aggregation instead of window functions
- Use DISTINCT ON for efficient top-finding selection per CVE
- Eliminate self-join on scan_vulnerability_findings table
- Add explicit type casting for Severity enum to text
- Reduce intermediate result sets for better performance

Frontend Pagination:
- Implement server-side pagination with configurable page size (50 items)
- Add automatic page reset when filters or search terms change
- Integrate with UnifiedTable serverPagination prop
- Display total count and current page information
- Support combined filtering (severity + search)

Performance Impact:
- Reduced query execution time through index utilization
- Efficient pagination with offset/limit at database level
- Proper handling of 414 total vulnerabilities across multiple pages
2025-10-04 15:59:01 -04:00
..