我有一个以字符串作为键,TileKey (下面的类)作为值的缓存,我注意到当我执行一个查询(下面)时,性能几乎是线性地受到缓存大小的影响,即使查询中使用的所有字段都是索引的。
下面是一个有代表性的基准测试--对于所有基准测试,我使用了相同的查询(下面)具有相同的参数:查询在所有基准测试中返回(相同)30个条目
我对8gb单节点和4gb 2节点执行了基准测试,结果基本相同(相对于缓存大小而言,查询速度)。
我还尝试使用QuerySqlFieldGroup,使用"time“字段作为第一个组字段,它应该将所有基准测试中的结果集减少到只有1000个条目,我不确定这是不是QuerySqlFieldGroup的正确用法,据我理解,它应该主要用于缓存之间的连接查询。
我是不是做错了什么,或者这些是使用Ignite索引所期望的查询性能?
代码:
String strQuery = "time = ? and zoom = ? and x >= ? and x <= ? and y >= ? and y <= ?";
SqlQuery<String, TileKey> query= new SqlQuery<String, TileKey>(TileKey.class, strQuery);
query.setArgs(time, zoom, xMin,xMax,yMin, yMax);
QueryCursor<Entry<String, TileKey>> tileKeyCursor = tileKeyCache.query(query);
Map<String, TileKey> tileKeyMap = new HashMap<String, TileKey>();
for (Entry<String, TileKey> p : keysCursor) {
tileKeyMap.put(p.getKey(), p.getValue());
}缓存配置:
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="KeysCache" />
<property name="cacheMode" value="PARTITIONED" />
<property name="atomicityMode" value="ATOMIC" />
<property name="backups" value="0" />
<property name="queryIndexEnabled" value="true"/>
<property name="indexedTypes">
<list>
<value>java.lang.String</value>
<value>org.ess.map.TileKey</value>
</list>
</property>
</bean>班级:
@QueryGroupIndex.List(@QueryGroupIndex(name = "idx1"))
public class TileKey implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private String id;
@QuerySqlField(index = true)
@QuerySqlField.Group(name = "idx1", order = 0)
private int time;
@QuerySqlField(index = true)
@QuerySqlField.Group(name = "idx1", order = 1)
private int zoom;
@QuerySqlField(index = true)
@QuerySqlField.Group(name = "idx1", order = 2)
private int x;
@QuerySqlField(index = true)
@QuerySqlField.Group(name = "idx1", order = 3)
private int y;
@QuerySqlField(index = true)
private boolean inCache;
}发布于 2015-08-16 10:33:17
https://stackoverflow.com/questions/31983395
复制相似问题