How to spead up query that calls the save view multiple times [message #684428] |
Tue, 01 June 2021 12:10  |
 |
helixpoint
Messages: 1 Registered: June 2021
|
Junior Member |
|
|
I have 3 select queries that are unioned. Each sect calls the same view. Is there any way I can only call it once
select m,n,p from
cars,
THEVIEW
union
select m,n,p from
cars2,
THEVIEW
union
select m,n,p from
carss,
THEVIEW
|
|
|
|
Re: How to spead up query that calls the save view multiple times [message #684430 is a reply to message #684428] |
Tue, 01 June 2021 12:51   |
 |
Michel Cadot
Messages: 68418 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
Something like:
select m,n,p
from THEVIEW,
(select ... from cars
union
select ... from cars2
union
select ... from carss)
Which does not mean it'd be better (in peformances terms).
With any SQL or PL/SQL question, please, post a working Test case: create table (including all constraints) and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.
Also always post your Oracle version, with 4 decimals (query v$version), as often solution depends on it.
|
|
|
Re: How to spead up query that calls the save view multiple times [message #684434 is a reply to message #684430] |
Wed, 02 June 2021 05:55  |
Solomon Yakobson
Messages: 3213 Registered: January 2010 Location: Connecticut, USA
|
Senior Member |
|
|
Michel,
select m,n,p
from THEVIEW,
(select ... from cars
union
select ... from cars2
union
select ... from carss)
Isn't equivalent to original. Equivalent would be:
select DISTINCT m,n,p
from THEVIEW,
(select ... from cars
union ALL
select ... from cars2
union ALL
select ... from carss)
But you're right OP needs to post whole query.
SY.
|
|
|