# SELECT * Query Optimization Analysis

## Found SELECT * Queries and Required Fields

### 1. `/home/ccuser/the-50-dollar-app/src/app/(authenticated)/dashboard/page.tsx`
**Query:** `supabase.from("profiles").select("*")`
**Used fields:**
- `type` (for contractor/worker logic)
- `name` (for greeting)
- `onboarding_completed` (for worker profile link)

**Optimization:** Replace with `.select("id, type, name, onboarding_completed")`

### 2. `/home/ccuser/the-50-dollar-app/src/app/(authenticated)/worker/profile/page.tsx`
**Query 1:** `supabase.from("profiles").select("*")`
**Used fields:**
- `onboarding_completed` (for redirect logic)
- `avatar_url` (for avatar display)
- `name` (for display name)
- `suburb` (for location)

**Optimization:** Replace with `.select("id, name, avatar_url, suburb, onboarding_completed")`

**Query 2:** `supabase.from("worker_profiles").select("*")`
**Used fields:**
- `trades` (for trade badges)
- `experience_years` (for experience label)
- `certifications` (for certifications section)
- `bio` (for bio section)
- `ai_extracted` (for skills)
- `availability` (for availability badge)

**Optimization:** Replace with `.select("profile_id, trades, experience_years, certifications, bio, ai_extracted, availability")`

### 3. `/home/ccuser/the-50-dollar-app/src/app/(authenticated)/worker/jobs/page.tsx`
**Query:** `supabase.from("jobs").select("*")`
**Used fields (based on Job type and usage):**
- `id` (for job identification)
- `title` (for display)
- `trade` (for trade filtering and display)
- `suburb` (for location display)
- `rate_min` (for rate display)
- `rate_max` (for rate display)
- `rate_type` (for rate type display)
- `start_date` (for date display)
- `workers_needed` (for worker count display)
- `status` (for filtering)
- `created_at` (for ordering)
- `location` (converted from PostgreSQL point to JSON)

**Optimization:** Replace with `.select("id, title, trade, suburb, rate_min, rate_max, rate_type, start_date, workers_needed, status, created_at, location")`

### 4. `/home/ccuser/the-50-dollar-app/src/app/(authenticated)/contractor/matches/page.tsx`
**Query 1:** `supabase.from("jobs").select("*")`
**Used fields:**
- `id` (for job identification)
- `company_id` (for filtering)
- `status` (for filtering)
- `created_at` (for ordering)

**Optimization:** Replace with `.select("id, company_id, status, created_at")`

**Query 2:** `supabase.from("matches").select("*")`
**Used fields:**
- `id` (for match identification)
- `job_id` (for job filtering)
- `status` (for status filtering)
- `match_score` (for match percentage)
- `ai_summary` (for AI summary)
- `contractor_action` (for action status)
- `worker_action` (for action status)
- `hired_at` (for hire status)
- `fee_charged` (for payment status)
- `created_at` (for ordering)

**Optimization:** Replace with `.select("id, job_id, status, match_score, ai_summary, contractor_action, worker_action, hired_at, fee_charged, created_at")`

### 5. `/home/ccuser/the-50-dollar-app/src/hooks/use-notifications.ts`
**Query:** `supabase.from("notifications").select("*")`
**Used fields (based on Notification type):**
- `id` (for identification)
- `profile_id` (for filtering)
- `type` (for notification type)
- `title` (for display)
- `body` (for display)
- `data` (for additional data)
- `read` (for read status)
- `created_at` (for ordering)

**Optimization:** Replace with `.select("id, profile_id, type, title, body, data, read, created_at")`

### 6. `/home/ccuser/the-50-dollar-app/src/app/api/payments/create/route.ts`
**Query:** `supabaseService.from('payments').upsert(...).select()`
**Used fields:** Need to check what fields are returned and used

**Optimization:** Replace with specific fields based on usage

### 7. `/home/ccuser/the-50-dollar-app/src/app/(authenticated)/worker/signup/page.tsx`
**Query:** `supabase.from("worker_profiles").insert(...).select()`
**Used fields:** Need to check what fields are returned and used

**Optimization:** Replace with specific fields based on usage