Posts

Showing posts from March 12, 2019

Adding an additional “order by” column gives me a much worse plan

Image
2 1 in other words, how can I get rid of the sort operator on the picture below? the picture above shows the execution plan of the following 2 selects together: SELECT TOP 1 so.OrgType, ch.Status, rcs.DBSstatusDescription, cid.ApplicationId FROM tbl_application_crb_initialData cid INNER JOIN tbl_season_organisationId so ON cid.OrganisationId = so.OrgId LEFT JOIN tbl_crbHistory ch ON cid.ClientReference = ch.ClientReference LEFT JOIN ref_crbStatus rcs ON ch.Status = rcs.statusId ORDER BY cid.DateAdded DES