提交 b30f9e1a authored 作者: Noel Grandin's avatar Noel Grandin

cache lookups into exprToIndexInGroupByData

now the test is both faster and uses less memory than originally
上级 f6f3a3d8
......@@ -96,7 +96,12 @@ public class Select extends Query {
* Key into groupByData that produces currentGroupByExprData. Not used in lazy mode.
*/
private ValueArray currentGroupsKey;
/**
* Cache the lookups into exprToIndexInGroupByData
*/
private Expression cachedLookup;
private Integer cachedLookupIndex;
private int havingIndex;
private boolean isGroupQuery, isGroupSortedQuery;
private boolean isForUpdate, isForUpdateMvcc;
......@@ -178,6 +183,8 @@ public class Select extends Query {
if (index == null) {
return null;
}
cachedLookup = expr;
cachedLookupIndex = index;
return currentGroupByExprData[index];
}
......@@ -185,6 +192,10 @@ public class Select extends Query {
* Set the group-by data for the current group and the passed in expression.
*/
public void setCurrentGroupExprData(Expression expr, Object obj) {
if (cachedLookup == expr) {
assert currentGroupByExprData[cachedLookupIndex] != null;
currentGroupByExprData[cachedLookupIndex] = obj;
}
Integer index = exprToIndexInGroupByData.get(expr);
if (index != null) {
assert currentGroupByExprData[index] != null;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论