我编写了这段代码来查询mysql表customerselections、company和companycampaigns。这些表具有必要字段的索引。
查询时间(无缓存)约为 0,30。考虑到并发连接,我认为查询时间很长。是否可以用不同的方式重写以加快查询时间?
SELECT
customerselections.customer_id,
customerselections.selectedcompany_id,
customerselections.selection_id,
companycampaigns.campaign_id,
companycampaigns.company_id,
companycampaigns.campaign_title,
companycampaigns.campaign_detail,
companycampaigns.published,
companies.company_logo,
companies.company_id,
FROM customerselections
LEFT JOIN companies ON customerselections.selectedcompany_id=companies.company_id
LEFT JOIN companycampaigns ON companycampaigns.company_id=companies.company_id AND companycampaigns.published='1'
WHERE customerselections.customer_id='$customerid' LIMIT $offset,$limit