MySQL Forums
Forum List  »  Newbie

View runs very slow
Posted by: Phil Siyam
Date: January 04, 2021 12:34PM

Hi, I created following sample view from 3 tables, result is slow 91 sec

Table 1 msa 15 Records index on att_id
Table 2 sa_con 1000 Records Index is on id
Table 3 sa_tab 33000 Records Index is on id


Create view tmp as
select sa.id ,sa.att_id, sa.value_desc
from msa
join sa_con on msa.att_id = sa_con.att_id
union all

select sa.id ,sa.att_id , sa.value_desc
from msa
join sa_tab on msa.att_id = sa_tab.att_id


select * from tmp where id = 100 Takes 91 seconds to show 2 records

If I run queries with where class, i get result in .05 sec to show 2 records

select sa.id ,sa.att_id, sa.value_desc value_desc
from msa
join sa_con on msa.att_id = sa_con.att_id
where id = 100
union all

select sa.id ,sa.att_id , sa.value_desc value_desc
from msa
join sa_tab on msa.att_id = sa_tab.att_id
where id = 100

Why is view slow? Any suggestions?

Thanks in advance
Wani

Options: ReplyQuote


Subject
Written By
Posted
View runs very slow
January 04, 2021 12:34PM
January 04, 2021 03:20PM
February 18, 2021 10:01AM
February 18, 2021 10:15AM


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.