0

以下のクエリには約 6 ~ 7 秒かかります。1秒以内に結果が欲しい。何をすればよいでしょうか。find_in_set で使用される catsid 列の索引付けは役立ちますか?

**EXPLAIN SELECT** sp_events.id,sp_events.id as speventId,
event.id as eventId,event.cityid as city_id,city.name as cityname,
event.title as event_name,event.title as eventName,
UNIX_TIMESTAMP(sp_events.dates) as sphinx_date,
sp_events.dates as sphinx_start_date,
UNIX_TIMESTAMP(sp_events.enddates) as sphinx_enddate,
sp_events.enddates as
sphinx_end_date,
UNIX_TIMESTAMP(event.dates) as date,event.dates as start_date,
UNIX_TIMESTAMP(event.enddates) as enddate,
event.enddates as end_date,
UNIX_TIMESTAMP(event.times) as times,
event.times as start_time,
TIME_TO_SEC(event.times) as sorttime,
TIME_TO_SEC(event.times) as startTime,
UNIX_TIMESTAMP(event.endtimes) as endtimes,
event.endtimes as end_time,event.booking_url,
event.image_low,event.preferred_image,
event.multiple_booking,event.recurrence_type,
event.recurrence_days,event.recurrence_times,
event.recurrence_endtimes,event.partner_url,event.partner_url_cc,
event.catsid as catsid,event.catsid as event_cat_id,
event.artist_id as aid,event.artist_id as artist_id,event.price,
event.partner,event.partner as eventpartner,
content.title as venue_name,content.title as venueName,
content.id as venueId,contact.latitude as lat,
contact.longitude as lon,RADIANS(contact.latitude) as lat1,
RADIANS(contact.longitude) as lon1,contact.city as venuecity,
city.countryid as country_id,event.image_high,
sd.stateCode 
**FROM** jos_sphinx_events as sp_events **LEFT JOIN** 
jos_eventlist_events as event ON sp_events.eventid = event.id **LEFT join** 
jos_content as content on content.id=event.locid **LEFT JOIN** 
jos_contact_details as contact ON content.id=contact.id **LEFT JOIN** 
jos_city_details as city on city.id=event.cityid **LEFT JOIN** 
jos_state_details as sd ON sd.id= city.stateid 
**WHERE** event.published='1'
      AND  event.enddates>=DATE_SUB(CURRENT_DATE(),INTERVAL 1 DAY)
      and  content.state='1'
      AND  city.published='1'
      AND  sp_events.eventid IN (
        SELECT  eventid
            FROM  jos_sphinx_events
            WHERE  (FIND_IN_SET(911,catsid)
                      OR  FIND_IN_SET(630,catsid)
                      OR  FIND_IN_SET(631,catsid)
                      OR  FIND_IN_SET(632,catsid)
                      OR  FIND_IN_SET(633,catsid)
                      OR  FIND_IN_SET(634,catsid)
                      OR  FIND_IN_SET(635,catsid)
                      OR  FIND_IN_SET(636,catsid)
                      OR  FIND_IN_SET(637,catsid)
                      OR  FIND_IN_SET(638,catsid)
                      OR  FIND_IN_SET(639,catsid)
                      OR  FIND_IN_SET(640,catsid)
                      OR  FIND_IN_SET(641,catsid)
                      OR  FIND_IN_SET(642,catsid)
                      OR  FIND_IN_SET(661,catsid)
                      OR  FIND_IN_SET(662,catsid)
                      OR  FIND_IN_SET(663,catsid)
                      OR  FIND_IN_SET(664,catsid)
                      OR  FIND_IN_SET(711,catsid)
                   )
              and  published='1'
              AND  enddates>=DATE_SUB(CURRENT_DATE(),INTERVAL 1 DAY)
              AND  enddates<=DATE_ADD(CURRENT_DATE(),INTERVAL 2 YEAR)
                          )
    limit  5

上記のクエリの Explain 結果は次のとおりです。 上記のクエリの Explain 結果は次のとおりです。

4

1 に答える 1