How do you optimize a slow-running SQL query that joins multiple large tables containing policyholder data?
Use the provided PostgreSQL tables to return metrics for policyholders with at least one active policy. Include only open claims filed during 2025. The result should avoid duplicate counting when a policyholder has multiple policies or claims.
policyholder_id, full_name, active_policy_count, open_claim_count, total_incurredpolicyholder_id ascending| Column | Type | Description |
|---|---|---|
| policyholder_idPK | INT | Unique policyholder identifier |
| full_name | VARCHAR(120) | Policyholder full name |
| state_code | VARCHAR(2) | Mailing state abbreviation |
| Column | Type | Description |
|---|---|---|
| policy_idPK | INT | Unique policy identifier |
| policyholder_id | INT | Policyholder owning the policy |
| policy_type | VARCHAR(30) | Type of insurance policy |
| policy_status | VARCHAR(20) | Current policy status |
| Column | Type | Description |
|---|---|---|
| claim_idPK | INT | Unique claim identifier |
| policy_id | INT | Policy associated with the claim |
| claim_status | VARCHAR(20) | Current claim status |
| filed_at | DATE | Date the claim was filed |
| incurred_amount | NUMERIC(12,2) | Incurred claim amount |