Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map Oracle date to Trino timestamp(0) type #10638

Merged
merged 2 commits into from
Jan 20, 2022

Conversation

ebyhr
Copy link
Member

@ebyhr ebyhr commented Jan 17, 2022

Fixes #10626

@cla-bot cla-bot bot added the cla-signed label Jan 17, 2022
@ebyhr
Copy link
Member Author

ebyhr commented Jan 17, 2022

Unfortunately, it's little hard to verify the Oracle execution plan on CI at this time. Here is the manual comparison results:

Create index on TPCH orders.orderdate column.

CREATE INDEX trino_test_orders ON trino_test.orders (orderdate);

TO_TIMESTAMP function

EXPlAIN PLAN FOR SELECT * FROM trino_test.orders WHERE orderdate > TO_TIMESTAMP('2011-01-01 01:01:01.11"', 'SYYYY-MM-DD HH24:MI:SS.FF');
SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY()); 

Plan hash value: 1275100350
 
----------------------------------------------------------------------------
| Id  | Operation         | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
----------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |        |   779 |   214K|    70   (3)| 00:00:01 |
|*  1 |  TABLE ACCESS FULL| ORDERS |   779 |   214K|    70   (3)| 00:00:01 |
----------------------------------------------------------------------------
 
Predicate Information (identified by operation id):
---------------------------------------------------
 
   1 - filter(INTERNAL_FUNCTION("ORDERDATE")>TO_TIMESTAMP('2011-01-01 
              01:01:01.11"','SYYYY-MM-DD HH24:MI:SS.FF'))
 
Note
-----
   - dynamic sampling used for this statement (level=2)

TO_DATE function

EXPlAIN PLAN FOR SELECT * FROM trino_test.orders WHERE orderdate > TO_DATE('2011-01-01 01:01:01.11"', 'SYYYY-MM-DD HH24:MI:SS.FF');
SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY()); 

Plan hash value: 1158690668
 
-------------------------------------------------------------------------------------------------
| Id  | Operation                   | Name              | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |                   |   997 |   274K|    67   (0)| 00:00:01 |
|   1 |  TABLE ACCESS BY INDEX ROWID| ORDERS            |   997 |   274K|    67   (0)| 00:00:01 |
|*  2 |   INDEX RANGE SCAN          | TRINO_TEST_ORDERS |   179 |       |     2   (0)| 00:00:01 |
-------------------------------------------------------------------------------------------------
 
Predicate Information (identified by operation id):
---------------------------------------------------
 
   2 - access("ORDERDATE">TO_DATE('2011-01-01 01:01:01.11"','SYYYY-MM-DD HH24:MI:SS.FF'))

@ebyhr ebyhr force-pushed the ebi/oracle-date-performance branch from 2810889 to ae6fb17 Compare January 17, 2022 07:34
@ebyhr ebyhr requested a review from hashhar January 17, 2022 08:14
@github-actions github-actions bot added the docs label Jan 18, 2022
@findepi
Copy link
Member

findepi commented Jan 18, 2022

@hashhar ptal

@ebyhr
Copy link
Member Author

ebyhr commented Jan 19, 2022

@hashhar Gentler reminder. I would like to include this PR into 369 because it's kind of regression in 368.

Copy link
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments. Looks good overall.

Will this break any views people have created using Hive connector over Oracle tables?

ebyhr added 2 commits January 20, 2022 13:29
This change fixes peformance regression
due to 77cfd97. TO_TIMESTAMP function with
date column led to full scan in Oracle side
when it's indexed column.
@ebyhr ebyhr force-pushed the ebi/oracle-date-performance branch from d7cfac6 to 2421203 Compare January 20, 2022 04:40
@ebyhr
Copy link
Member Author

ebyhr commented Jan 20, 2022

Will this break any views people have created using Hive connector over Oracle tables?

It won't break existing views. The original column definition timestamp(3) would be respected unless they re-create views.

@ebyhr ebyhr merged commit c0afeb5 into trinodb:master Jan 20, 2022
@ebyhr ebyhr deleted the ebi/oracle-date-performance branch January 20, 2022 06:14
@github-actions github-actions bot added this to the 369 milestone Jan 20, 2022
@ebyhr ebyhr mentioned this pull request Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

TO_TIMESTAMP on Oracle DATE type generates inefficient plan in case of indexed column
3 participants