What are the primary strategies for reducing unnecessary database hits?
Demonstrate the set-based approach with one PostgreSQL query that retrieves active Depop listings, seller usernames, and whether user 1 has liked each listing. Include listings even when seller or like data is missing.
listing_id, listing_title, seller_username, liked_by_user, liked_at.created_at, then descending listing_id.| Column | Type | Description |
|---|---|---|
| idPK | INT | User identifier |
| username | VARCHAR(80) | Depop username |
| is_active | BOOLEAN | Whether the account is active |
| Column | Type | Description |
|---|---|---|
| idPK | INT | Listing identifier |
| seller_id | INT | User who created the listing |
| title | VARCHAR(150) | Listing title |
| status | VARCHAR(20) | Listing lifecycle status |
| created_at | TIMESTAMP | Listing creation timestamp |
| Column | Type | Description |
|---|---|---|
| idPK | INT | Like identifier |
| listing_id | INT | Liked listing |
| user_id | INT | User who liked the listing |
| created_at | TIMESTAMP | Time the like was created |