-
Notifications
You must be signed in to change notification settings - Fork 15
Remove dead DBKVS code, fix Oracle hints #7338
Conversation
Generate changelog in
|
@@ -28,27 +28,18 @@ public interface DbQueryFactory { | |||
|
|||
FullQuery getLatestRowsQuery(Iterable<byte[]> rows, long ts, ColumnSelection columns, boolean includeValue); | |||
|
|||
FullQuery getLatestRowsQuery( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These methods are all unused, so deleted from this interface and the Postgres/Oracle implementation classes.
+ " SELECT" | ||
+ " /*+ USE_NL(t m) LEADING(t m) CARDINALITY(t 1) CARDINALITY(m 10) INDEX(m " | ||
+ PrimaryKeyConstraintNames.get(tableName) + ") */ " | ||
String query = "SELECT" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the hints here are simply wrong - there is no table alias t.
More generally:
-
Hints of the form INDEX(alias PrimaryKeyConstraintNames.get(tableName)) are redundant because in the Oracle implementation of DBKVS, all these tables are Index Organised Tables (IOT) for which the only access is via the index (caveat being if there were secondary indexes on the non-key columns of the IOT we wanted to use such a hint could make sense - but there are not). Specifying an INDEX hint doesn't preclude Oracle from using a non-ideal scan method eg fast full scan, range scan etc) - it just says use this particular index. So these hints provide no utility whatsoever.
-
Where we have USE_NL(t m) LEADING (t m) we are providing a verify specific access pathway that can only be interpreted one way. The CARDINALITY hints are thus redundant (these provide Oracle with expected counts from each table) because they would normally be fed to the optimiser to help it formulate a plan. But since we've stipulated a plan with USE_NL/LEADING, the cardinality is irrelevant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I imagine the t m
references are probably copied from somewhere, but you're right, they don't make sense here.
Confirmed that:
- we use
ORGANIZATION INDEX
in creating the tables (OracleDdlTable:285) - on that basis, the
INDEX
hint on the primary key index is redundant - for this query, there is no join/product to speak of, so
USE_NL
andLEADING
don't make sense.
@@ -373,15 +276,16 @@ protected FullQuery getRowsColumnRangeSubQuery( | |||
@Override | |||
protected FullQuery getRowsColumnRangeFullyLoadedRowsSubQuery( | |||
List<byte[]> rows, long ts, ColumnRangeSelection columnRangeSelection) { | |||
String query = " /* GET_ROWS_COLUMN_RANGE_FULLY_LOADED_ROWS (" + tableName + ") */ " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't duplicate the query "name" - the wrapQueryWithIncludeValue wraps these inner queries, and we only need to specify the name there - once.
@@ -373,15 +276,16 @@ protected FullQuery getRowsColumnRangeSubQuery( | |||
@Override | |||
protected FullQuery getRowsColumnRangeFullyLoadedRowsSubQuery( | |||
List<byte[]> rows, long ts, ColumnRangeSelection columnRangeSelection) { | |||
String query = " /* GET_ROWS_COLUMN_RANGE_FULLY_LOADED_ROWS (" + tableName + ") */ " | |||
+ "SELECT * FROM ( SELECT m.row_name, m.col_name, max(m.ts) as ts" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove redundant outer select, ie:
SELECT * FROM (X) -> X
+ " WHERE m.row_name = t.row_name " | ||
+ " AND m.ts < ? " | ||
String query = "SELECT" | ||
+ " /*+ USE_NL(t m) LEADING(t m) */" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this hint where there was not one. In response to issue seen on #pds-594762 where we observed a plan:
rather than the expected/sensible form:
Operation | Options | Object Name | Cardinality | Bytes | Cost
---------------------------------------- | -------------------------------- | -------------------------------- | ------------ | ------------ | ------------
SELECT STATEMENT | | | 0 | 0 | 1959
SORT | ORDER BY | | 1627 | 109009 | 1959
NESTED LOOPS | | | 1627 | 109009 | 1959
VIEW | | | 1627 | 47183 | 330
HASH | GROUP BY | | 1627 | 39048 | 330
NESTED LOOPS | | | 1627 | 39048 | 329
COLLECTION ITERATOR | PICKLER FETCH | | 100 | 200 | 29
INDEX | RANGE SCAN | PK_PT_MET_OBJ_PARENT_LINKS_ACL | 16 | 352 | 3
INDEX | UNIQUE SCAN | PK_PT_MET_OBJ_PARENT_LINKS_ACL | 1 | 38 | 2
I've confirmed that our internal products that actually use oracle still compile with this change. +1 to removing unused methods. The other changes also look correct to me. |
Apologies for the delay here, team has been beleaguered with some brutal support issues last week. Picking this back up on my end... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Thanks for submitting this!
I confirmed that outside of the specific query we looked at in getRowsColumnRangeFullyLoadedRowsSubQuery
where we added the USE_NL and LEADING hints, all other changes to queries were one of
- removing
INDEX
from queries on an IOT table - removing
CARDINALITY
from queries that haveUSE_NL
andLEADING
- removing "names" from queries that already are wrapped in named queries in only one possible way
- removing
USE_NL
andLEADING
from queries that don't actually have a join
+ " SELECT" | ||
+ " /*+ USE_NL(t m) LEADING(t m) CARDINALITY(t 1) CARDINALITY(m 10) INDEX(m " | ||
+ PrimaryKeyConstraintNames.get(tableName) + ") */ " | ||
String query = "SELECT" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I imagine the t m
references are probably copied from somewhere, but you're right, they don't make sense here.
Confirmed that:
- we use
ORGANIZATION INDEX
in creating the tables (OracleDdlTable:285) - on that basis, the
INDEX
hint on the primary key index is redundant - for this query, there is no join/product to speak of, so
USE_NL
andLEADING
don't make sense.
+ " /*+ USE_NL(t m) LEADING(t m) CARDINALITY(t 1) CARDINALITY(m 10) INDEX(m " | ||
+ PrimaryKeyConstraintNames.get(tableName) + ") */ " | ||
String query = "SELECT" | ||
+ " /*+ USE_NL(t m) LEADING(t m) */ " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cardinality hint from above.
Released 0.1181.0 |
==COMMIT_MSG==
Oracle hints/query improved; dead DBKVS code removed
==COMMIT_MSG==
Priority:
High, see #pds-594762