[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] [metrics-web/master 1/5] Improve relay search performance.
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Fri, 10 Dec 2010 07:01:00 +0100
Subject: Improve relay search performance.
Commit: 15dca69745fc000a5563a9607968d3409f0a9729
Our relay search consists of two nested SELECTs with the inner SELECT
returning the valid-after times of matching status entries. In that
statement, we shouldn't GROUP BY valid-after times and limit the result to
31 rows. We should rather return the last 31 valid-after times regardless
whether they're overlapping or not. This saves us a lot of join steps in
the outer SELECT resulting in rows that we're going to throw away anyway,
because the outer SELECT is limited to 31 rows, too.
---
.../torproject/ernie/web/RelaySearchServlet.java | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/src/org/torproject/ernie/web/RelaySearchServlet.java b/src/org/torproject/ernie/web/RelaySearchServlet.java
index c5fb242..305f792 100644
--- a/src/org/torproject/ernie/web/RelaySearchServlet.java
+++ b/src/org/torproject/ernie/web/RelaySearchServlet.java
@@ -367,8 +367,7 @@ public class RelaySearchServlet extends HttpServlet {
System.currentTimeMillis() - 30L * 24L * 60L * 60L * 1000L)
+ "' ");
}
- queryBuilder.append("GROUP BY validafter ORDER BY validafter DESC "
- + "LIMIT 31) AND ");
+ queryBuilder.append("ORDER BY validafter DESC LIMIT 31) AND ");
queryBuilder.append(conditionBuilder.toString());
queryBuilder.append("ORDER BY validafter DESC, fingerprint LIMIT 31");
String query = queryBuilder.toString();
--
1.7.1