当我在 mysql 中运行以下查询时,需要 78 秒才能显示记录。还有其他方法可以编写此查询。这是我的mysql查询->“
select distinct nuqta1.post_id from wp_postmeta as nuqta1
inner join wp_postmeta as nuqta2 on (nuqta1.post_id = nuqta2.post_id)
inner join wp_postmeta as nuqta4 on (nuqta1.post_id = nuqta4.post_id)
inner join wp_postmeta as nuqta5 on (nuqta1.post_id = nuqta5.post_id)
inner join wp_postmeta as nuqta6 on (nuqta1.post_id = nuqta6.post_id)
inner join wp_postmeta as nuqta7 on (nuqta1.post_id = nuqta7.post_id)
inner join wp_postmeta as nuqta8 on (nuqta1.post_id = nuqta8.post_id)
inner join wp_postmeta as nuqta9 on (nuqta1.post_id = nuqta9.post_id)
inner join wp_postmeta as nuqta10 on (nuqta1.post_id = nuqta10.post_id)
inner join wp_postmeta as nuqta11 on (nuqta1.post_id = nuqta11.post_id)
inner join wp_postmeta as nuqta12 on (nuqta1.post_id = nuqta12.post_id)
where (nuqta2.meta_key = 'checkin' and nuqta2.meta_value LIKE '%10/31/2012%')
and (nuqta4.meta_key = 'guests' and nuqta4.meta_value ='1')
and (nuqta5.meta_key = 'roomtype' and nuqta5.meta_value LIKE '%Entire home/apt%')
and (nuqta6.meta_key = 'price' and cast(nuqta6.meta_value as signed) BETWEEN '10' and '99999')
and (nuqta7.meta_key = 'amenities' and nuqta7.meta_value LIKE '%Wireless Internet%')
and (nuqta8.meta_key = 'amenities' and nuqta8.meta_value LIKE '%TV%')
and (nuqta9.meta_key = 'amenities' and nuqta9.meta_value LIKE '%Kitchen%')
and (nuqta10.meta_key = 'amenities' and nuqta10.meta_value LIKE '%Wireless Internet%')
and (nuqta11.meta_key = 'amenities' and nuqta11.meta_value LIKE '%TV%')
and (nuqta12.meta_key = 'amenities' and nuqta12.meta_value LIKE '%Kitchen%')
and 1=1 order by nuqta1.post_id asc
“。而且我正在使用 wordpress 表 wp_postmeta 来运行这个查询