首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用In-Clause查询Apache的性能

使用In-Clause查询Apache的性能
EN

Stack Overflow用户
提问于 2022-07-18 20:11:06
回答 1查看 71关注 0票数 0

我在Apache中创建了一个模式,其中有10列,其中3列是set索引(例如A、B是字符串类型,C是int类型)。行总数约为40,000,000行。下面是如何创建缓存表:

代码语言:javascript
复制
CacheConfiguration<AffinityKey<Long>, Object> cacheCfg = new CacheConfiguration<>();
cacheCfg.setName(CACHE_NAME);
cacheCfg.setDataRegionName("MY_DATA_REGION");
cacheCfg.setBackups(1);

QueryEntity queryEntity = new QueryEntity(AffinityKey.class, Object.class)
        .setTableName("DataCache")
        .addQueryField("Field_A", String.class.getName(), null)
        .addQueryField("Field_B", String.class.getName(), null)
        .addQueryField("Field_C", Integer.class.getName(), null)
        .addQueryField("Field_D", Integer.class.getName(), null);

List<QueryIndex> queryIndices = new ArrayList<>();
List<String> groupIndices = new ArrayList<>();
groupIndices.add("Field_A");
groupIndices.add("Field_B");
groupIndices.add("Field_C");
queryIndices.add(new QueryIndex(groupIndices, QueryIndexType.SORTED));
queryEntity.setIndexes(queryIndices);
cacheCfg.setQueryEntities(Arrays.asList(queryEntity));
ignite.getOrCreateCache(cacheCfg);

我试图使用sql语句查询点燃缓存,如

代码语言:javascript
复制
select * from DataCache where 
Field_A in (...) and Field_B in (...) and Field_C in (...)

每一句都有1000~5000长度。查询速度不快,甚至比直接查询谷歌大查询还要慢。我只是想知道,在使用in-子句sql时,是否有任何方法可以提高查询性能。

EN

回答 1

Stack Overflow用户

发布于 2022-07-19 08:23:45

您没有说明如何创建表,但我猜您有三个索引,每列一个。我怀疑您需要创建一个组指数,即跨三列创建一个索引。在in子句中有这么多元素,将其重写为联接也可能是有益的。

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

https://stackoverflow.com/questions/73028069

复制
相关文章

相似问题

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