I have a big table with over a two million items.
I have a SQL selection to get items selected by some WHERE informations but my call is not really fast.
Is there a way to get faster call?
That is my call now
SELECT id, name, price, pricebefore, link, imagelink, updated, site, siteid 
        FROM items 
        WHERE (case when pricebefore3 is NULL then pricebefore else pricebefore3*1.5 end) >= pricebefore 
        AND price < pricebefore 
        AND isbn != -1 
        AND 1 = CASE
          WHEN (100-price/pricebefore*100) > 90 THEN updated < NOW() - INTERVAL ".$timeago." MINUTE
          ELSE (100-price/pricebefore*100) > ".mysqli_real_escape_string($link, $percentage)." 
        END
        ".preg_quote($merchant)."
        ORDER BY updated DESC 
        LIMIT ".mysqli_real_escape_string($link, $perPage)." 
        OFFSET ".mysqli_real_escape_string($link, $site);
The id is primary in the table.
All others like name, siteid, price and everything is index
I tried much more SQL calls but i dont find any faster way... any ideas to make the SQL Call faster? The Table is InnoDB with utf8mb4_0900_ai_ci
The SQL call checks where the price is lower than before. I have a crawler that get prices from sites and changed it to pricebefore when get new one. The "Price" is the current price, so it shows the item when the price is lower than pricebefore
All other WHERe is just for time interval or isbn = -1 if i dont want to show it and something.
In merchant i put a regex to find just a few shops and not all sites
