I have large table with 615 million records in items and 10 thousand in markets
the below query takes 5+ seconds to execute
how can I make it faster. ?
SELECT items.name,items.ID as itemID,items.market_id as market_id,markets.name as marketname
from items,markets
where markets.ID = items.market_id and
items.name like '%bab%'
group by items.name
order by items.name ASC
limit 0,10
Explain
-> Limit: 10 row(s) (actual time=4657.094..4657.096 rows=9 loops=1)
-> Sort: items.`name`, limit input to 10 row(s) per chunk (actual time=4657.093..4657.094 rows=9 loops=1)
-> Table scan on <temporary> (actual time=0.002..0.003 rows=9 loops=1)
-> Temporary table with deduplication (cost=1141592.47 rows=625722)
(actual time=4657.070..4657.072 rows=9 loops=1)
-> Nested loop inner join (cost=1141592.47 rows=625722) (actual time=0.056..4541.471 rows=85329 loops=1)
-> Filter: (items.`name` like \'%bab%\') (cost=593647.14 rows=625722) (actual time=0.043..4456.394 rows=85329 loops=1)
-> Table scan on items (cost=593647.14 rows=5632061) (actual time=0.037..2864.754 rows=6153656 loops=1)
-> Single-row index lookup on markets using PRIMARY (ID=items.market_id) (cost=0.78 rows=1) (actual time=0.001..0.001 rows=1 loops=85329)