Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Optimizing View Performance with Large Data Set and ORDER BY Clause

zoulfikar fahsSep 10 2024

Hi,

I am currently working on a view and have been tasked with improving its performance. The execution time of the view is around 38 seconds, but when I remove the ORDER BY clause, the time decreases to 0.7 seconds. The challenge is that I still need to keep the ORDER BY clause in place. No matter which column I use in the ORDER BY clause, the execution time doesn't drop below 35 seconds. The output of the view is nearly 150,000 rows.

The view is written as follows:

CREATE OR REPLACE VIEW view_name AS

SELECT COLUMNS_NAME
FROM
(
SELECT COLUMNS_NAME
FROM TABLE_NAME
WHERE CONDITION

UNION ALL

SELECT COLUMNS_NAME
FROM TABLE_NAME
WHERE CONDITION
)
ORDER BY COLUMN_NAME;

This post has been answered by Cookiemonster76 on Sep 10 2024
Jump to Answer
Comments
Post Details
Added on Sep 10 2024
14 comments
2,747 views