clustered-index - Apache Ignite 索引性能

标签 clustered-index gridgain ignite

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

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

  • 查询 5350 个条目缓存花费了 6-7 毫秒
  • 查询 10700 个条目缓存需要 8-10 毫秒
  • 查询 48150 个条目缓存花费了 30-42 毫秒
  • 查询 96300 个条目缓存花费了 50-70 毫秒

我使用 8GB 单节点和 4GB 2 节点执行了基准测试,结果几乎相同(就查询速度相对于缓存大小而言)

我还尝试通过使用“时间”字段作为第一个组字段来使用 QuerySqlFieldGroup,它应该将所有基准测试中的结果集减少到只有 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;
}

最佳答案

我已经找到问题了,谢谢 bobby_brew 引导我走向正确的方向。

indexing example Ignite 的错误,有一个 open issue关于它。

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

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

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

现在在所有场景中查询持续时间都是稳定的 2 毫秒

关于clustered-index - Apache Ignite 索引性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31983395/

相关文章:

ignite:使用 igniteCache 时 strip 池中可能出现饥饿

java - 设置 Ignite 计算网格的 RAM 大小

sql - 数据库表中的可搜索日期字段是否应该始终被索引?

sql-server-2005 - 我应该怎么做才能获得聚集索引查找而不是聚集索引扫描?

数据库索引

java - GridGain:如何在同一个JVM中运行多个节点?

sql-server - 主键在sql server中总是有索引吗?

datagrid - 如何在 Apache Ignite 中启用 Visor 命令行?

amazon-ec2 - AWS 上的 GridGain 集群在 VPC 中使用 TcpDiscoverySpi,而不是集群

grails - Apache Ignite 在启动时挂起