From 35e62e03e92db31f22c4674e154ffa83229e90da Mon Sep 17 00:00:00 2001 From: Brokkonaut Date: Fri, 2 Nov 2018 23:57:12 +0100 Subject: [PATCH] order results by id only (date is not needed there) --- .../java/de/diddiz/LogBlock/QueryParams.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/de/diddiz/LogBlock/QueryParams.java b/src/main/java/de/diddiz/LogBlock/QueryParams.java index 99d689c..4405abe 100644 --- a/src/main/java/de/diddiz/LogBlock/QueryParams.java +++ b/src/main/java/de/diddiz/LogBlock/QueryParams.java @@ -98,7 +98,7 @@ public final class QueryParams implements Cloneable { public String getFrom() { if (sum != SummarizationMode.NONE) { - throw new IllegalStateException("No implemented for summarization"); + throw new IllegalStateException("Not implemented for summarization"); } if (bct == BlockChangeType.CHAT) { String from = "FROM `lb-chat` "; @@ -123,13 +123,6 @@ 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) "; } @@ -150,14 +143,21 @@ public final class QueryParams implements Cloneable { public String getOrder() { if (sum != SummarizationMode.NONE) { - throw new IllegalStateException("No implemented for summarization"); + throw new IllegalStateException("Not implemented for summarization"); } - return "ORDER BY date " + order + ", id " + order + " "; + + // heuristics, for small time spans this might be faster + final int twoDaysInSeconds = 60 * 24 * 2; + if (since > 0 && since <= twoDaysInSeconds) { + return "ORDER BY date " + order + ", id " + order + " "; + } + + return "ORDER BY id " + order + " "; } public String getFields() { if (sum != SummarizationMode.NONE) { - throw new IllegalStateException("No implemented for summarization"); + throw new IllegalStateException("Not implemented for summarization"); } if (bct == BlockChangeType.CHAT) { String select = "";