Slow query LEFT OUTER JOIN Mysql?

Ensure you have an index on the field "cc46_cc55_field_id_id". In addition, don't use your list of almost 200 IDs... Since your version is all sequential, just use a BETWEEN clause SELECT DISTINCT b. Cc46_cc55_field_id_id AS row_id, t0.

Cc46_value AS f_264, t1. Cc46_value AS f_265, t2. Cc46_value AS f_266 FROM tc46_fields_values be LEFT JOIN tc46_fields_values t0 ON b.

Cc46_cc55_field_id_id = t0. Cc46_cc55_field_id_id AND t0. Cc46_cc26_field_id = 264 LEFT JOIN tc46_fields_values t1 ON b.

Cc46_cc55_field_id_id = t1. Cc46_cc55_field_id_id AND t1. Cc46_cc26_field_id = 265 LEFT OUTER JOIN tc46_fields_values t2 ON b.

Cc46_cc55_field_id_id = t2. Cc46_cc55_field_id_id AND t2. Cc46_cc26_field_id = 266 WHERE b.

Cc46_cc55_field_id_id between 5924 and 6166.

Ensure you have an index on the field "cc46_cc55_field_id_id". In addition, don't use your list of almost 200 IDs... Since your version is all sequential, just use a BETWEEN clause.. SELECT DISTINCT b. Cc46_cc55_field_id_id AS row_id, t0.

Cc46_value AS f_264, t1. Cc46_value AS f_265, t2. Cc46_value AS f_266 FROM tc46_fields_values be LEFT JOIN tc46_fields_values t0 ON b.

Cc46_cc55_field_id_id = t0. Cc46_cc55_field_id_id AND t0. Cc46_cc26_field_id = 264 LEFT JOIN tc46_fields_values t1 ON b.

Cc46_cc55_field_id_id = t1. Cc46_cc55_field_id_id AND t1. Cc46_cc26_field_id = 265 LEFT OUTER JOIN tc46_fields_values t2 ON b.

Cc46_cc55_field_id_id = t2. Cc46_cc55_field_id_id AND t2. Cc46_cc26_field_id = 266 WHERE b.

Cc46_cc55_field_id_id between 5924 and 6166.

Rather horrid field names, I must say. Good answer, that aside ;P – JamWaffles Oct 10 at 23:36 I wish I could up-vote this twice. Once for supplying a good answer that is probably right (missing indexes are the prime reason for slow queries), and once for taking the time to reformat that godawful query.

– Ben Lee Oct 10 at 23:47.

To see what indexes are used run EXPLAIN SELECT DISTINCT b. Cc46_cc55_field_id_id AS row_id, t0. Cc46_value AS f_264, t1.

Cc46_value AS f_265, t2. Cc46_value AS f_266 FROM tc46_fields_values be LEFT JOIN tc46_fields_values t0 ON b. Cc46_cc55_field_id_id = t0.

Cc46_cc55_field_id_id AND t0. Cc46_cc26_field_id = 264 LEFT JOIN tc46_fields_values t1 ON b. Cc46_cc55_field_id_id = t1.

Cc46_cc55_field_id_id AND t1. Cc46_cc26_field_id = 265 LEFT OUTER JOIN tc46_fields_values t2 ON b. Cc46_cc55_field_id_id = t2.

Cc46_cc55_field_id_id AND t2. Cc46_cc26_field_id = 266 WHERE b. Cc46_cc55_field_id_id between 5924 and 6166.

Try to this query instead: SELECT b. Cc46_cc55_field_id_id AS row_id, t0. Cc46_value AS f_264, t1.

Cc46_value AS f_265, t2. Cc46_value AS f_266 FROM tc46_fields_values be LEFT OUTER JOIN tc46_fields_values t0 ON b. Cc46_cc55_field_id_id = t0.

Cc46_cc55_field_id_id LEFT OUTER JOIN tc46_fields_values t1 ON b. Cc46_cc55_field_id_id = t1. Cc46_cc55_field_id_id LEFT OUTER JOIN tc46_fields_values t2 ON b.

Cc46_cc55_field_id_id = t2. Cc46_cc55_field_id_id WHERE t0. Cc46_cc26_field_id = 264 AND t1.

Cc46_cc26_field_id = 265 AND t2. Cc46_cc26_field_id = 266 AND b. Cc46_cc55_field_id_id IN (5924,5925,5926,5927,5928,5929,5930,5931,5932,5933,5934,5935,5936,5937,5938,5939,5940,5941,5942,5943,5944,5945,5946,5947,5948,5949,5950,5951,5952,5953,5954,5955,5956,5957,5958,5959,5960,5961,5962,5963,5964,5965,5966,5967,5968,5969,5970,5971,5972,5973,5974,5975,5976,5977,5978,5979,5980,5981,5982,5983,5984,5985,5986,5987,5988,5989,5990,5991,5992,5993,5994,5995,5996,5997,5998,5999,6000,6001,6002,6003,6004,6005,6006,6007,6008,6009,6010,6011,6012,6013,6014,6015,6016,6017,6018,6019,6020,6021,6022,6023,6024,6025,6026,6027,6028,6029,6030,6031,6032,6033,6034,6035,6036,6037,6038,6039,6040,6041,6042,6043,6044,6045,6046,6047,6048,6049,6050,6051,6052,6053,6054,6055,6056,6057,6058,6059,6060,6061,6062,6063,6064,6065,6066,6067,6068,6069,6070,6071,6072,6073,6074,6075,6076,6077,6078,6079,6080,6081,6082,6083,6084,6085,6086,6087,6088,6089,6090,6091,6092,6093,6094,6095,6096,6097,6098,6099,6100,6101,6102,6103,6104,6105,6106,6107,6108,6109,6110,6111,6112,6113,6114,6115,6116,6117,6118,6119,6120,6121,6122,6123,6124,6125,6126,6127,6128,6129,6130,6131,6132,6133,6134,6135,6136,6137,6138,6139,6140,6141,6142,6143,6144,6145,6146,6147,6148,6149,6150,6151,6152,6153,6154,6155,6156,6157,6158,6159,6160,6161,6162,6163,6164,6165,6166) GROUP BY b.

Cc46_cc55_field_id_id instead of using distinct use group by.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions