我在Apache中创建了一个模式,其中有10列,其中3列是set索引(例如A、B是字符串类型,C是int类型)。行总数约为40,000,000行。下面是如何创建缓存表:
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语句查询点燃缓存,如
select * from DataCache where
Field_A in (...) and Field_B in (...) and Field_C in (...)每一句都有1000~5000长度。查询速度不快,甚至比直接查询谷歌大查询还要慢。我只是想知道,在使用in-子句sql时,是否有任何方法可以提高查询性能。
发布于 2022-07-19 08:23:45
您没有说明如何创建表,但我猜您有三个索引,每列一个。我怀疑您需要创建一个组指数,即跨三列创建一个索引。在in子句中有这么多元素,将其重写为联接也可能是有益的。
https://stackoverflow.com/questions/73028069
复制相似问题