Use FSCR information to ommit empty data pages while performing Table Scan (TBSCAN)
Table scan over volatile table with large number of empty pages scans all empty pages instead of using FSCR to find pages to be scanned.
DB2 9.7.FP5 on Linux / DB2 9.7.FP9a on AIX 7.1 / DB2 10.5.FP4 on Linux
In this scenario SQL replication uses staging tables - the tables are filled and then emptied regularly (reorg table is not a solution for this case). Some of them has grown quite large exceeding 400 thousand pages. These tables have no indexes on them, thus any SQL run against the tables uses table scan.
As was found out, even when the table is empty with no rows (all data pages are empty) the table scan causes engine to scan all the empty pages. This leads to increased CPU utilization and negative performance impact. It seems that DB2 does not use the information from FSCR to avoid reading empty pages, which seems to be a logical solution to this problem. Altering the table as volatile does not have any impact on the problem.
Implement a solution that ommits scanning of empty data pages when performing Table Scan.
This above scenario can be easily solved by appropriately scanning pages identified by FSCR and held locks. Namely if a table scan is chosen by the optimizer, then DB2 shall read all the pages identified as not empty thru FSCR, and additionally (depending on the isolation level) all the empty pages, that have still exclusive locks on them. Such empty page with exclusive lock on it means, the page was not empty before, and was emptied by a delete, which is not committed yet. In such a case a UNCOMMITTED READ isolation level does not need to read the empty pages, as it will not find any data there. But for example COMMITTED READ isolation level still has to go thru the empty pages, which still have locks on them, as there might be deleted rows, that were not committed yet. This solution causes that empty pages, that were commited (there are no locks on them) do not have to be read anymore, thus improving performance and lowering the amount of resources required for queries performing such table scans. Such solution, for all isolation levels other than UNCOMMITTED READ, still requires going thru lock list to check if there are any locks placed on empty pages, but it is much shorter and less resource consuming than reading all the empty pages from disk.
This kind of solution is implemented successfully in IBM Informix Dynamic Server for decades. As DB2 got different mechanims like HADR, partitioned tables, db2pd, etc. from Informix Dynamic Server, then maybe it shall also get optimal table scan from Informix as well.