Query takes forever to run

Hi,

​

I have a table (oracle DB v12) with 22 columns and running the the following query which for some reason either runs for 30 min or takes forever. The expected result is to get most recent timestamp per user_id. What am I doing wrong and what could be an alternative?

select user_id, dept_id
from main.personal
where (user_id, int_timestamp) in (
    select user_id, max(int_timestamp) as latest_update
    from main.personal
    group by user_id
)

​

Thank you!

Posted Jan 4, 2023, 6:24 PM UTC

76
Loading comments…