MySQL Forums
Forum List  »  General

Union view performance improvement
Posted by: kj csb
Date: July 26, 2016 04:05AM

I have created the following view:
CREATE
VIEW `ALL_CALLS_UNION` AS
select
a.field1,
a.field2
from
a
union
b.field1,
b.field2
from
b

When I run the following query it takes forever
select * from ALL_CALLS_UNION
where field1 = 123;

When I run the following query it completes in seconds
select
a.field1,
a.field2
from
a
where a.field1 = 123
union
b.field1,
b.field2
from
b
where b.field1 = 123;

Is there a way I can rewrite the view to perform better?

Options: ReplyQuote


Subject
Written By
Posted
Union view performance improvement
July 26, 2016 04:05AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.