Heavy query in MRole repeated too often (FHCA-3883)

Description

The DBA from FH suggested if is possible to cache this very frequent query:

SELECT AD_Table_ID, AccessLevel, TableName, IsView,(SELECT ColumnName FROM AD_COLUMN WHERE AD_COLUMN.AD_TABLE_ID = AD_TABLE.AD_TABLE_ID AND upper(AD_COLUMN.COLUMNNAME)= upper(AD_TABLE.TABLENAME ||'_ID'))FROM AD_Table WHERE IsActive='Y';

Environment

None

Activity

Peter Takacs 
June 8, 2023 at 12:20 PM

Reopening due to a bug in logic discovered and fixed by .

In MRole.java:980 the columnExists(columnName) method is checking if the given column exists on AD_Table instead of the correct table (since the MTable class represents AD_Table and the columnExists(columnName) method is in PO).

Carlos Ruiz 
September 5, 2022 at 6:37 PM

Analyzing the method MRole.loadTableInfo:


load all private -> private

HashMap<Integer,String>
m_tableAccessLevel
AD_Table_ID + AccessLevel
used just in MRole.isTableAccessLevel
String roleAccessLevel = (String)m_tableAccessLevel.get(Integer.valueOf(AD_Table_ID));

HashMap<String,Integer>
m_tableName
TableName + AD_Table_ID
used just in MRole.getAD_Table_ID
Integer ii = (Integer)m_tableName.get(tableName);

Set<String>
m_viewName
UPPER(Tablename) WHEN IsView=Y
used just in MRole.isView
return m_viewName.contains(tableName.toUpperCase());

HashMap<String,String>
m_tableIdName
UPPER(Tablename) + ID_ColumnName (when exists)
used just in MRole.getIdColumnName
return m_tableIdName.get(tableName.toUpperCase());

 

All those variables are intended to be a quick in-memory access, however all of them can be replaced by access to cached information from table and columns.

The pull request 1465 implements this approach.

Fixed

Details

Assignee

Reporter

Fix versions

Priority

Created September 5, 2022 at 5:18 PM
Updated August 1, 2023 at 5:26 PM
Resolved June 9, 2023 at 8:36 AM