Anti join + Join to prevent complex query
EXPLAIN analyze select * from asset_headers join asset_assignee_mappings on asset_headers.org_id = asset_assignee_mappings.org_id and asset_headers.id = asset_assignee_mappings.asset_id ORDER BY assignee_id LIMIT 10;
-- assignee id - null -> select asset header left join condition is failed
-- or
-- assignee id = x -> select join union (don't left join)
Left Join vs Join
Left join can't use indexing, but join can.