Can you perform a join on two massive tables while minimizing memory usage?
Write a PostgreSQL query that returns matching active records from both tables. The approach should avoid unnecessary rows and columns before joining, while preserving duplicate matches for the same join key.
a_record_id, b_record_id, join_key, a_payload, b_payloada_record_id, then b_record_id| Column | Type | Description |
|---|---|---|
| record_idPK | BIGINT | Unique identifier for a record in table A |
| join_key | BIGINT | Key used to match records across both tables |
| is_active | BOOLEAN | Whether the record is eligible for joining |
| payload | VARCHAR(100) | Payload value from table A |
| Column | Type | Description |
|---|---|---|
| record_idPK | BIGINT | Unique identifier for a record in table B |
| join_key | BIGINT | Key used to match records across both tables |
| is_active | BOOLEAN | Whether the record is eligible for joining |
| payload | VARCHAR(100) | Payload value from table B |