[ 
https://issues.apache.org/jira/browse/IGNITE-22776?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17869268#comment-17869268
 ] 

Ignite TC Bot commented on IGNITE-22776:
----------------------------------------

{panel:title=Branch: [pull/11448/head] Base: [master] : No blockers 
found!|borderStyle=dashed|borderColor=#ccc|titleBGColor=#D6F7C1}{panel}
{panel:title=Branch: [pull/11448/head] Base: [master] : New Tests 
(6)|borderStyle=dashed|borderColor=#ccc|titleBGColor=#D6F7C1}
{color:#00008b}Queries 3 (lazy=true){color} [[tests 
3|https://ci2.ignite.apache.org/viewLog.html?buildId=8002425]]
* {color:#013220}IgniteBinaryCacheQueryLazyTestSuite3: 
StatisticsObsolescenceTest.testObsolescenceWithInsert - PASSED{color}
* {color:#013220}IgniteBinaryCacheQueryLazyTestSuite3: 
StatisticsObsolescenceTest.testObsolescenceWithDelete - PASSED{color}
* {color:#013220}IgniteBinaryCacheQueryLazyTestSuite3: 
StatisticsObsolescenceTest.testObsolescenceWithUpdate - PASSED{color}

{color:#00008b}Queries 3{color} [[tests 
3|https://ci2.ignite.apache.org/viewLog.html?buildId=8002424]]
* {color:#013220}IgniteBinaryCacheQueryTestSuite3: 
StatisticsObsolescenceTest.testObsolescenceWithInsert - PASSED{color}
* {color:#013220}IgniteBinaryCacheQueryTestSuite3: 
StatisticsObsolescenceTest.testObsolescenceWithDelete - PASSED{color}
* {color:#013220}IgniteBinaryCacheQueryTestSuite3: 
StatisticsObsolescenceTest.testObsolescenceWithUpdate - PASSED{color}

{panel}
[TeamCity *--> Run :: All* 
Results|https://ci2.ignite.apache.org/viewLog.html?buildId=8002453&buildTypeId=IgniteTests24Java8_RunAll]

> SQL table statistic is updated only once.
> -----------------------------------------
>
>                 Key: IGNITE-22776
>                 URL: https://issues.apache.org/jira/browse/IGNITE-22776
>             Project: Ignite
>          Issue Type: Bug
>    Affects Versions: 2.15
>            Reporter: Vladimir Steshin
>            Priority: Major
>              Labels: ise
>             Fix For: 2.17
>
>         Attachments: StatisticsObsolescenceTest.java
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> 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:sql}
> ANALYZE MY_TABLE
> {code}
> But table statistic tends to update with CRUD only once. Despite the 
> obsolescence threshold, by default
> {code:java}
> int StatisticsObjectConfiguration#DEFAULT_OBSOLESCENCE_MAX_PERCENT = 15;
> {code}
> 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}
> Regarding my research, the problem is within
> {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 
> {code:java}
> v.modified() (long ObjectPartitionStatisticsObsolescence#modified())
> {code}
> is always 0, never updates.  Probably because 
> {code:java}
> IgniteStatisticsManagerImpl#calculateObsolescencedPartitions#onRowUpdated(String
>  schemaName, String objName, int partId, byte[] keyBytes) 
> {code}
> is called nowhere. But
> {code:java}
> partStat.rowCount()
> {code}
> is 0 at the beginning. This is why the statistic is calculated once.
> A workaroung might be setting the threshold to a negative value:
> {code:java}
> ANALYZE MY_TABLE WITH MAX_CHANGED_PARTITION_ROWS_PERCENT=-1
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to