首页 文章

Apache Ignite索引性能

提问于
浏览
4

我有一个带字符串作为键的缓存和TileKey(下面的类)作为值,我注意到当我执行查询(下面)时,即使使用了所有字段,性能也会受到缓存大小的线性影响 . 在查询中被索引 .

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

  • 查询5350条目缓存需要6-7ms

  • 查询10700条目缓存需要8-10ms

  • 查询48150条目缓存需要30-42ms

  • 对96300条目缓存的查询耗时50-70ms

我用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;
}

1 回答

  • 5

    我找到了问题,谢谢bobby_brew带领我朝着正确的方向前进 .

    Ignite的indexing example不正确,有关于它的open issue .

    我已经更改了索引字段注释

    @QuerySqlField(index = true)
       @QuerySqlField.Group(name = "idx1", order = x)
    

    @QuerySqlField(index = true, orderedGroups = {@QuerySqlField.Group(name = "idx1", order = x)})
    

    现在,在所有情况下查询持续时间都是2ms

相关问题