help for multi column index for mysql

Discussion in 'MySQL' started by trichnosis, Apr 8, 2009.

  1. #1
    Hi;

    I own some joomla 1.5 web sites. the most common query for joomla 1.5 is below. my jos_content table has over 112k records. that query is taking too much time to pull data

    SELECT a.id, a.title, a.alias, a.title_alias, a.introtext, a.fulltext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by, a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, a.images, a.attribs, a.urls, a.metakey, a.metadesc, a.access, CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(':', a.id, a.alias) ELSE a.id END AS slug, CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END AS catslug, CHAR_LENGTH( a.`fulltext` ) AS readmore, u.name AS author, u.usertype, g.name AS groups, u.email AS author_email, cc.title AS category, s.title AS section, s.ordering AS s_ordering, cc.ordering AS cc_ordering, a.ordering AS a_ordering, f.ordering AS f_ordering
    FROM jos_content AS a
    INNER JOIN jos_content_frontpage AS f
    ON f.content_id = a.id
    LEFT JOIN jos_categories AS cc
    ON cc.id = a.catid
    LEFT JOIN jos_sections AS s
    ON s.id = a.sectionid
    LEFT JOIN jos_users AS u
    ON u.id = a.created_by
    LEFT JOIN jos_groups AS g
    ON a.access = g.id
    WHERE 1
    AND a.access <= 0
    AND a.state = 1
    AND (( cc.published = 1
    AND s.published = 1 ) OR ( a.catid = 0
    AND a.sectionid = 0 ) )
    AND ( a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '2009-04-08 16:14:51' )
    AND ( a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '2009-04-08 16:14:51' )
    ORDER BY a.created DESC

    can you suggest me any multicolumn index for that type of query?

    Regards
     
    trichnosis, Apr 8, 2009 IP
  2. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #2
    The use of OR should be avoided.

    Can you post EXPLAIN results?
     
    mwasif, Apr 11, 2009 IP