创建临时表非常慢

时间:2018-03-20 04:18:43

标签: mysql

我正在创建临时表,以便对此数据做出一些关键决策。但是我发现我的临时表创建过程非常缓慢,只需要3万分钟即可完成900k行。我想优化这个过程,请让我知道技术,以优化我的插入速度。

CREATE TEMPORARY TABLE temp_listing_summary_update 
SELECT 
  l.selector,
  l.userid,
  b.broker_id,
  a.agentid,
  firmstate,
  IF(
    firmstate IN ('on', 'edited'),
    1,
    IF(
      firmstate IN ('Rejected'),
      - 1,
      IF(
        firmstate IN ('expired'),
        2,
        IF(
          firmstate IN ('pDeleted', 'Deleted'),
          3,
          0
        )
      )
    )
  ) AS firmstate_order,
  l.is_mgz_listing,
  l.mgz_added_date,
  l.dev_id,
  l.listing_is_verified,
  a.flag AS agent_flag 
FROM
  xx_ldxlistings l 
  INNER JOIN xx_ldxcategory c 
    ON l.listing_cat_id = c.cat_id 
  LEFT JOIN xx_ldxusers_relation ur 
    ON l.userid = ur.userid 
    AND ur.role_id = 1 
  LEFT JOIN xx_ldxagents a 
    ON a.agentid = ur.object_id 
  LEFT JOIN xx_ldxagents_brokers b 
    ON l.userid = b.userid 
  LEFT JOIN xx_ldxlistings_images li 
    ON l.selector = li.listing_id 
    AND li.status = 'on' 
  LEFT JOIN xx_ldxlistings_features lf 
    ON l.selector = lf.listing_id 
WHERE l.date_refresh '2018-03-17 04:20:01' 
GROUP BY l.selector 

0 个答案:

没有答案