High CPU - Mysql From Query - Please Help

Discussion in 'MySQL' started by skins4webs, Feb 1, 2010.

  1. #1
    I've been absolutely stuck on this horrible issue for a while.

    PHP Code

    Queries
    Them queries within three page loads, will rise the cpu to 90 percent.

    I seem to have all the indexes in place, what could possibly be going on, what can I do to fix it?
     
    skins4webs, Feb 1, 2010 IP
  2. draginx

    draginx Peon

    Messages:
    53
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What does your table schema look like?
     
    draginx, Feb 1, 2010 IP
  3. skins4webs

    skins4webs Well-Known Member

    Messages:
    383
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    128
    #3
    Myisam

    mysql> explain  Select DISTINCT i.name, i.price, i.sale, i.item_number, i.rating, i.rating_average, a.value as 'brand'                  FROM Inventory i, Departments_Data d, Groups g, Attributes a, Attributes_Data ad                  WHERE i.active = 1 AND                  d.id=1 AND                  d.item = i.item_number AND                  g.name = 'brand' AND                  g.id = a.group_id AND                  ad.attribute_id = a.id AND                  ad.item = i.item_number                   ORDER BY i.price DESC                  LIMIT 792, 24;
    +----+-------------+-------+--------+----------------------------------+-------------+---------+---------------------------------+-------+---------------------------------+
    | id | select_type | table | type   | possible_keys                    | key         | key_len | ref                             | rows  | Extra                           |
    +----+-------------+-------+--------+----------------------------------+-------------+---------+---------------------------------+-------+---------------------------------+
    |  1 | SIMPLE      | d     | ref    | item,id,id_2,item_2              | id          | 4       | const                           | 11437 | Using temporary; Using filesort | 
    |  1 | SIMPLE      | i     | ref    | PRIMARY,active,item_number       | item_number | 32      | mydb.d.item          |     1 | Using where                     | 
    |  1 | SIMPLE      | ad    | ref    | attribute_id,item,attribute_id_2 | item        | 57      | mydb.i.item_number   |     1 | Using where                     | 
    |  1 | SIMPLE      | a     | eq_ref | PRIMARY,group_id,group_id_2      | PRIMARY     | 4       | mydb.ad.attribute_id |     1 |                                 | 
    |  1 | SIMPLE      | g     | eq_ref | PRIMARY                          | PRIMARY     | 4       | mydb.a.group_id      |     1 | Using where; Distinct           | 
    +----+-------------+-------+--------+----------------------------------+-------------+---------+---------------------------------+-------+---------------------------------+
    5 rows in set (0.00 sec)
    Code (markup):
    That's an example, tell me if that helps you any.
     
    skins4webs, Feb 1, 2010 IP