Search code examples
sqloracle-databaseoracle12cquery-performance

Is the character "A" a reserved keyword in Oracle Database?


scenario: In Oracle Database, This SQL it's much slower:

SELECT * 
FROM TBL_MAIN A, TBL_CHILD_1 B, TBL_CHILD_2 C, TBL_CHILD_3 D, TBL_CHILD_4 E
WHERE A.ID_MAIN = B.ID_MAIN 
AND A.ID_MAIN = C.ID_MAIN 
AND A.ID_MAIN = D.ID_MAIN 
AND A.ID_MAIN = E.ID_MAIN;

than that:

SELECT * 
FROM TBL_MAIN X, TBL_CHILD_1 B, TBL_CHILD_2 C, TBL_CHILD_3 D, TBL_CHILD_4 E
WHERE X.ID_MAIN = B.ID_MAIN 
AND X.ID_MAIN = C.ID_MAIN 
AND X.ID_MAIN = D.ID_MAIN 
AND X.ID_MAIN = E.ID_MAIN;

In other words, When I have 3 or more tables joined if I use "A" as an aliasing for "TBL_MAIN" table, it results in a slower query.

It becomes worst when I added more tables in an inner join with table "TBL_MAIN" AS "A".

What is happening?


Solution

  • The problem solved itself! Now the two SQL has the same time, just a little faster like @wolφi said.

    This scenario was going on for two days, but now its normal.

    I believe after a shutdown the database became normal.

    An interesting thing about this is when the problems were happening, SQL Tuning Advisor suggested an execution plan for the SQL who make work normal (99,9 % faster). unfortunately, I didn't save recommendation report in that time to show here.

    but now without any SQL profile active, the SQL's are with the same time.