bda6533105
- 移至 openspec/changes/archive/2026-05-25-api-performance-optimization/ - 新增主規格:api-cache-layer、db-index-optimization - 更新 review-lifecycle 規格(補分頁、eager load) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1.2 KiB
1.2 KiB
ADDED Requirements
Requirement: Notifications 表補複合索引
notifications 表 SHALL 新增 [notifiable_type, notifiable_id, read_at] 複合索引,以加速 unreadNotifications() 查詢。
Scenario: Migration 執行成功
- WHEN 執行
php artisan migrate - THEN
notifications表上存在notifications_notifiable_read_at_index(或同等命名的)複合索引,EXPLAIN結果不再為 full table scan
Scenario: 未讀通知查詢走索引
- WHEN 系統執行
Notification::where('notifiable_type', User::class)->where('notifiable_id', $userId)->whereNull('read_at')->get() - THEN MySQL
EXPLAIN顯示使用複合索引,type為ref而非ALL
Requirement: DivingOffers 表補 provider_id 索引
diving_offers 表 SHALL 新增 provider_id 單欄索引,以加速 Provider 課程列表查詢。
Scenario: Migration 執行成功
- WHEN 執行
php artisan migrate - THEN
diving_offers表上存在provider_id索引
Scenario: Provider 課程列表查詢走索引
- WHEN 系統執行
DivingOffer::where('provider_id', $providerId)->get() - THEN MySQL
EXPLAIN顯示使用provider_id索引,type為ref