dbaspot
Tags Register FAQ Calendar Search Today's Posts Mark Forums Read

Simple sql using distinct and union too slow - Oracle Database

This is a discussion on Simple sql using distinct and union too slow - Oracle Database ; Here is a query select distinct fiscal_year, accounting_period from ps_ledger union select distinct fiscal_year, accounting_period from ps_ledger_kk union select distinct fiscal_year, accounting_period from ps_ledger_budg The tables have about 1 million rows each. Here is the explain plan Operation Object Name ...


Home > Database Forum > Oracle Database > Simple sql using distinct and union too slow

Reply

 

LinkBack Thread Tools Display Modes
  #1  
Old 11-12-2008, 12:55 PM
Database Newbie
 
Join Date: Nov 2008
Posts: 1
gmerabella is on a distinguished road
Default Simple sql using distinct and union too slow

Here is a query
select distinct fiscal_year, accounting_period
from ps_ledger
union
select distinct fiscal_year, accounting_period
from ps_ledger_kk
union
select distinct fiscal_year, accounting_period
from ps_ledger_budg

The tables have about 1 million rows each.

Here is the explain plan

Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop

SELECT STATEMENT Optimizer Mode=ALL_ROWS 32 27811
SORT UNIQUE 32 253 27811
UNION-ALL
INDEX FAST FULL SCAN SYSADM.PSFLEDGER 1 M 11 M 5598
INDEX FAST FULL SCAN SYSADM.PSALEDGER_KK 948 K 7 M 7389
INDEX FAST FULL SCAN SYSADM.PS_LEDGER_BUDG 363 K 2 M 3064

It takes about 5 secs. I want it to run in 1 sec or less. Any ideas?
Reply With Quote
Reply

Thread Tools
Display Modes



All times are GMT -4. The time now is 08:27 AM.