prefix . 'actionwear_images'; $index_exists = $wpdb->get_results("SHOW INDEX FROM $images_table WHERE Key_name = 'idx_images_sku'"); if (empty($index_exists)) { $wpdb->query("CREATE UNIQUE INDEX idx_images_sku ON $images_table (sku)"); } // Add index on actionwear_products.brand_name for brand-based queries $products_table = $wpdb->prefix . 'actionwear_products'; $brand_index_exists = $wpdb->get_results("SHOW INDEX FROM $products_table WHERE Key_name = 'idx_products_brand'"); if (empty($brand_index_exists)) { $wpdb->query("CREATE INDEX idx_products_brand ON $products_table (brand_name)"); } } } }