首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Apache索引性能

Apache索引性能
EN

Stack Overflow用户
提问于 2015-08-13 08:42:08
回答 1查看 2.2K关注 0票数 4

我有一个以字符串作为键,TileKey (下面的类)作为值的缓存,我注意到当我执行一个查询(下面)时,性能几乎是线性地受到缓存大小的影响,即使查询中使用的所有字段都是索引的。

下面是一个有代表性的基准测试--对于所有基准测试,我使用了相同的查询(下面)具有相同的参数:查询在所有基准测试中返回(相同)30个条目

  • 查询5350个条目缓存花费了6-7ms
  • 查询10700个条目缓存花费了8-10 on。
  • 查询48150项缓存花费了30-42 30。
  • 查询96300项缓存花费了50-70 50。

我对8gb单节点和4gb 2节点执行了基准测试,结果基本相同(相对于缓存大小而言,查询速度)。

我还尝试使用QuerySqlFieldGroup,使用"time“字段作为第一个组字段,它应该将所有基准测试中的结果集减少到只有1000个条目,我不确定这是不是QuerySqlFieldGroup的正确用法,据我理解,它应该主要用于缓存之间的连接查询。

我是不是做错了什么,或者这些是使用Ignite索引所期望的查询性能?

代码:

代码语言:javascript
复制
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());
}

缓存配置:

代码语言:javascript
复制
<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>

班级:

代码语言:javascript
复制
@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;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-08-16 10:33:17

我发现了问题,谢谢bobby_brew带领我走向正确的方向。

Ignite的索引示例是不正确的,它有一个公开发行

我已经将索引字段注释从

代码语言:javascript
复制
   @QuerySqlField(index = true)
   @QuerySqlField.Group(name = "idx1", order = x)

代码语言:javascript
复制
@QuerySqlField(index = true, orderedGroups = {@QuerySqlField.Group(name = "idx1", order = x)})

现在,在所有场景中,查询持续时间都是坚实的2ms。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31983395

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档