diff --git a/src/main/java/de/diddiz/LogBlock/QueryParams.java b/src/main/java/de/diddiz/LogBlock/QueryParams.java index 5314268..99d689c 100644 --- a/src/main/java/de/diddiz/LogBlock/QueryParams.java +++ b/src/main/java/de/diddiz/LogBlock/QueryParams.java @@ -122,6 +122,14 @@ public final class QueryParams implements Cloneable { } String from = "FROM `" + getTable() + "-blocks` "; + + // heuristics - for a small radius using coords index is much faster, but mysql sometimes does not use it + if ((loc != null && radius <= 500) || (sel != null && sel.getSizeX() <= 1000)) { + if (since < 0 || since > 11000) { + from += "USE INDEX (coords) "; + } + } + if (needPlayer || players.size() > 0) { from += "INNER JOIN `lb-players` USING (playerid) "; }