I am writing a request to select a playerโs prohibitions from another table, but, firstly, its very slow reception takes about 7-14 seconds, and secondly, it returns invalid lines.
The first request is as follows:
SELECT * FROM sourcebans.sb_bans WHERE removetype IS NULL AND removedon IS NULL AND reason NOT LIKE '%[FragSleuth] Duplicate account%' AND ip IN(SELECT DISTINCT ip FROM fragsleuth.history WHERE trackingid = "ad000c3803b48190aabf382e01b957c9") OR authid IN(SELECT DISTINCT steamid FROM fragsleuth.history WHERE trackingid = "ad000c3803b48190aabf382e01b957c9")
The second query is as follows
SELECT * FROM `history` WHERE trackingid = "ad000c3803b48190aabf382e01b957c9"
And a few screenshots to show what I mean: First request Second request
In screenshot 1, you can see that its return string, where removeon and type of deletion are not null, when I asked the query to only return strings with NULL.
I also fear that inside the history table there will be duplicate entries for steamid and ip columns that can make the query slow, is there a way to make the query only select rows with a unique ip or steamid based on trackingid?
Any help would be greatly appreciated.
thanks
Edit: help overwhelms me, thanks to @maraca, @Skorpioh and @Adam Silenko, the request time is less than a second!
source share