Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > MySQL > MySQL General forum

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-02-2008, 05:04 AM
Ananda Kumar
 
Posts: n/a
Default query tuning.

Hi All,
I am using mysql 5.0.41, on debian, with 8 CPU, 8 GB RAM.

I am having the below query with explain plan

select * from (select * from (select truncate((((0.34*LOG(10,((NO_BIDS +
1)/(TOTAL_QTY
+ 1)))) + (0.24*LOG(10,100*( (SOLD_QTY + 1) / (TOTAL_QTY + 1)))) + 0.14*(1
/ LOG(10, 10 + TOTAL_QTY / NO_SLRS))) * 100),2) as CLUSTER_RANK,
LEAF_CATEG_ID, CD.CLUSTER_ID, SIGNATURE, NO_LISTINGS, NO_SUCC_LISTINGS, ASP,
NO_BIDS, MIN_PRICE, MAX_PRICE, NO_SLRS,
TOTAL_QTY, SOLD_QTY from Cluster_data CD where CD.cluster_id in ( select
B2.child_cluster_id from cluster_hierarchy B2
LEFT JOIN cluster_hierarchy B1 ON B2.child_cluster_id=B1.cluster_id where
B1.cluster_id IS NULL and B2.child_cluster_id
in
(123781710012,123781710015,123781710023,1237817100 24,123781710031,123781710033,123781710035,12378171 0067,123781710067,123781710069))
LIMIT 500 )X order by 1 DESC ) Y where CLUSTER_RANK > 29 LIMIT 30

+----+--------------------+-------+------+-------------------------+-------------------------+---------+------------------------------+-------+-----------------------------------------------------+
| id | select_type | table | type | possible_keys |
key | key_len | ref | rows |
Extra |
+----+--------------------+-------+------+-------------------------+-------------------------+---------+------------------------------+-------+-----------------------------------------------------+
| 1 | PRIMARY | NULL | NULL | NULL |
NULL | NULL | NULL | NULL |
Impossible WHERE noticed after reading const tables |
| 2 | DERIVED | NULL | NULL | NULL |
NULL | NULL | NULL | NULL |
no matching row in const table |
| 3 | DERIVED | CD | ALL | NULL |
NULL | NULL | NULL | 12752 |
Using where |
| 4 | DEPENDENT SUBQUERY | B2 | ref | CH_CCI_IDX_0803120214 |
CH_CCI_IDX_0803120214 | 10 | func | 3 |
Using where; Using index |
| 4 | DEPENDENT SUBQUERY | B1 | ref | KD_KW_KI_IDX_0803120214 |
KD_KW_KI_IDX_0803120214 | 10 | research.B2.child_cluster_id | 4 |
Using where; Using index; Not exists |
+----+--------------------+-------+------+-------------------------+-------------------------+---------+------------------------------+-------+-----------------------------------------------------+

mysql> show index from cluster_data;
+--------------+------------+-----------------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index |
Column_name | Collation | Cardinality | Sub_part | Packed | Null |
Index_type | Comment |
+--------------+------------+-----------------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+
| cluster_data | 0 | PRIMARY | 1 |
cluster_id | A | 12752 | NULL | NULL | |
BTREE | |
| cluster_data | 1 | CD_LCI_IDX_0803120214 | 1 |
leaf_categ_id | A | 2 | NULL | NULL | |
BTREE | |
+--------------+------------+-----------------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+

Is there any options for me to tune this query. Here in the test
envirionment CD table has only 12752 rows, but actually in productin it will
have close to 8 Million rows. So with the above explain plan, the query
would take too much time as its reading FULL TABLE on CD.

Can you please help me in tuning this query. Also the "IN" clause will have
close to 1000 values at any time.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 05:21 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145