Vladimir Steshin created IGNITE-22776:
-----------------------------------------
Summary: SQL table statistic is updated only once.
Key: IGNITE-22776
URL: https://issues.apache.org/jira/browse/IGNITE-22776
Project: Ignite
Issue Type: Bug
Reporter: Vladimir Steshin
To build a better plan, H2 can rely on the statistics. We can enable it with
{code:java}
control. Sh --property set --name 'statistics. Usage. State' --val 'ON'
{code}
and
{code:java}
ANALYZE MY_TABLE
{code}
But table statistic tends not to be update with CRUD even there is an
obsolescence threshold. By default
{code:java}
int StatisticsObjectConfiguration#DEFAULT_OBSOLESCENCE_MAX_PERCENT = 15;
{code}
Regarding my research, partition statistics obsolescence is checked every 60
seconds:
{code:java}
int IgniteStatisticsManagerImpl#OBSOLESCENCE_INTERVAL = 60;
if (serverNode) {
obsolescenceSchedule = ctx.timeout().schedule(() -> {
obsolescenceBusyExecutor.execute(() -> processObsolescence());
}, OBSOLESCENCE_INTERVAL * 1000, OBSOLESCENCE_INTERVAL * 1000);
}
{code}
The problem seems to reside in
{code:java}
private Set<Integer>
IgniteStatisticsManagerImpl#calculateObsolescencedPartitions(
StatisticsObjectConfiguration cfg,
IntMap<ObjectPartitionStatisticsObsolescence> parts
) {
Set<Integer> res = new HashSet<>();
parts.forEach((k, v) -> {
ObjectPartitionStatisticsImpl partStat =
statsRepos.getLocalPartitionStatistics(cfg.key(), k);
if (partStat == null || partStat.rowCount() == 0 ||
(double)v.modified() * 100 / partStat.rowCount() >
cfg.maxPartitionObsolescencePercent())
res.add(k);
});
// Will add even empty list of partitions to recollect just to force
obsolescence info to be stored.
return res;
}
{code}
Where `v.modified()` (`long ObjectPartitionStatisticsObsolescence#modified()`)
is always 0. never updates. Probably because
{code:java}
IgniteStatisticsManagerImpl#calculateObsolescencedPartitions#onRowUpdated(String
schemaName, String objName, int partId, byte[] keyBytes)
{code}
is called nowhere.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)