我有以下mySQL查询,完全正常.除了我需要添加"FORCE INDEX",我不确定我必须在哪里做到这一点.我尝试了几乎每个位置,并始终收到mySQL错误.我究竟做错了什么?
这是原始查询:
$sql_select_recent_items = $db->query("SELECT * FROM (SELECT owner_id, product_id, start_time, price, currency, name, closed, active, approved, deleted, creation_in_progress FROM db_products ORDER BY start_time DESC) as resultstable
WHERE resultstable.closed=0 AND resultstable.active=1 AND resultstable.approved=1 AND resultstable.deleted=0 AND resultstable.creation_in_progress=0
GROUP BY resultstable.owner_id
ORDER BY start_time DESC");
Run Code Online (Sandbox Code Playgroud)
查询以这种方式构造,以便我可以在"GROUP BY"之前执行"ORDER BY",以防您想知道.
我需要补充的是:
FORCE INDEX (products_start_time)
Run Code Online (Sandbox Code Playgroud)
我在几乎没有成功的地方试过它,这让我相信有一些我更缺失的东西更复杂?