Hi All,
one of my customer sent me a query generate by JDBC driver 15.00.00.20 to get some metadata. the execution of the query is not performant. I analyse the query and find that the where condition on databasename and tablename are write with LIKE (below I report only the where condition part of the query):
WHERE t.TableKind IN ('O','T','V')
AND t.DatabaseName (NOT CASESPECIFIC) LIKE TRIM(TRAILING FROM 'Q_TC0_KPE_KPI') (NOT CASESPECIFIC)
AND t.TableName (NOT CASESPECIFIC) LIKE TRIM(TRAILING FROM 'RET_ABBINAMENTO_CAMPO') (NOT CASESPECIFIC)
With this where condition TERADATA optimization generate not a good plan even if we define the correspondant stats on where condition columns (as you know, if we use like TD cannot use the stats information).
I change the quey simply substituing the LIKE operator with = (equal) operator:
WHERE t.TableKind IN ('O','T','V')
AND t.DatabaseName (NOT CASESPECIFIC) = TRIM(TRAILING FROM 'Q_TC0_KPE_KPI') (NOT CASESPECIFIC)
AND t.TableName (NOT CASESPECIFIC) = TRIM(TRAILING FROM 'RET_ABBINAMENTO_CAMPO') (NOT CASESPECIFIC)
In this way I can run the query with a very short elapsed (with the original version the query never end because in the plan we have a product join between 2 big spool !).
Is there a way to modify the query generate by JDBC driver ?
Why the driver use LIKE instead of '=' ?
thank you very match.
Forums: