I have two oracle select queries like
SELECT loc.location AS LOCATION , req.requisition AS REQ
FROM location_view loc, requisition_view req, association ass
WHERE loc.name = 'ABC' AND req.name = 'TRANSFER'
AND ass.entity_id_2 = req.entity_id AND ass.entity_id_1 = loc.entity_id
And the result looks like:
Other query is like:
SELECT req.requisition AS req, exp.experiment AS expt
FROM experiment_view exp, requisition_view req, association_view ass
WHERE expt.name = 'RETRIEVAL'AND req.name = 'TRANSFER'
AND ass.entity_id_2 = req.entity_id AND ass.entity_id_1 = expt.entity_id
Result:
I am trying to combine these two SELECT
queries so I get to see these results:
Should I be using Sub-Queries to see the combined result or is there any other way of optimizing?
The following recommendations will help you in your SQL tuning process.
You'll find 3 sections below:
CREATE INDEX association_idx_entity_2_entity_1 ON association (entity_id_2,entity_id_1);
CREATE INDEX location_view_idx_name_entity_id ON location_view (name,entity_id);
CREATE INDEX requisition_view_idx_name_entity_id ON requisition_view (name,entity_id);
SELECT
loc.location AS LOCATION,
req.requisition AS REQ
FROM
location_view loc,
requisition_view req,
association ass
WHERE
loc.name = 'ABC'
AND req.name = 'TRANSFER'
AND ass.entity_id_2 = req.entity_id
AND ass.entity_id_1 = loc.entity_id