Re: index not being pick up
Posted by:
Raf Mahn
Date: January 21, 2018 04:31PM
I tried reversing the join, unfortunately the index was still not picked up.
create or replace algorithm=merge view `vw_property`
as select property.*
FROM `flag` join property where (`property`.`scope_id` = flag.`scope_id` or flag.`override_enabled` = true)
with check option;
explain select * from vw_property where reference = "200ADELAIDE";
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE flag ALL scopeid_idx,override_enabled_idx NULL NULL NULL 1 NULL
1 SIMPLE property ALL uq_reference_idx NULL NULL NULL 5 Using where; Using join buffer (Block Nested Loop)
The presence of the union also prevents me from making the view updatable.
If I change the index to be (reference, scope_id), it will pick up index. Though, since scope_id is our column to make the table multi-tenancy, we wanted to keep it on the left as I'm hoping to be able to use the scope_id for other queries instead of needing to create more indexes in the future.
Seems like creating multiple views is way to go.
Subject
Views
Written By
Posted
1368
January 15, 2018 11:57PM
584
January 16, 2018 12:19AM
525
January 16, 2018 04:39PM
556
January 16, 2018 07:49PM
575
January 17, 2018 12:26AM
548
January 17, 2018 01:07AM
773
January 17, 2018 01:19AM
575
January 17, 2018 12:41PM
548
January 19, 2018 07:26AM
Re: index not being pick up
554
January 21, 2018 04:31PM
514
January 21, 2018 05:41PM
602
January 22, 2018 03:00AM
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.