0

I have a problem. I want to fetch last 10 rows of two table (live_st and load_balace) joined together that have an ip ending with 134. both table have millions of data.

I tried this query in mysql :

SELECT live_stats.domain_name
FROM live_stats JOIN load_balance
ON live_stats.user_id=load_balance.unique_id
WHERE load_balance.ip_address like '%134'
ORDER BY  live_stats.created desc limit 10;  

its worked but too slow . is there any way to speed up the query; thanks for advance;

Noble
  • 77
  • 7
  • If you can split the `ip_address` column to 4 `TINYINT` columns, you could change the `WHERE load_balance.ip_address like '%134'` condition to `WHERE load_balance.ip_address_4 = 134` and index could be used. Otherwise, any query with `LIKE '%something'` is not likely to use any index so a table scan on `load_balance` will be performed. – ypercubeᵀᴹ Mar 01 '13 at 09:21
  • tables are not modifiable.thanks and i think the order by clause take the bad for this dalay – Noble Mar 01 '13 at 09:41

0 Answers0