Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- Requirement: Select all bookings that are shared to factory_id = 194592 or supplier_id = 201670 ---
- --- Using OR condition ---
- explain analyze
- select count(*) from inspections_booking ib left outer join inspections_customorgcontactlocation f on ib.factory_information_id = f.id
- left outer join inspections_customorgcontactlocation s on ib.supplier_information_id = s.id
- where f.org_id = 194592 or s.org_id = 201670
- --- Using UNION ---
- explain analyze
- select count(*) from (
- select ib.* from inspections_booking ib inner join inspections_customorgcontactlocation f on ib.factory_information_id = f.id where f.org_id = 194592
- union
- select ib.* from inspections_booking ib inner join inspections_customorgcontactlocation s on ib.supplier_information_id = s.id where s.org_id = 201670
- ) as ib
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement