I am very confused by the plans available for this simple query which uses a foreign key as a filter.

My understanding is accountid on Contact is indexed since it is a primary key and I have given a pretty tight filter by only providing on accountid but the plan tool still says the indexed plan has 2.4 cost.

Also this is way below the selectivity thresholds because it is only retrieving one record.

I am not sure what I am missing here. Can somebody explain?

enter image description here

  • Do you have many contacts not linked to accounts? or deleted contacts? I can't remember, but do person accounts also result in contacts being created?
    – Nick C
    Mar 20, 2023 at 6:50
  • Not sure what "many" would constitute but I wouldn't say we don't have any contacts with Accounts. Not sure how that would affect this? And yes person accounts do count as Account & contact but we don't use person accounts in our org. Mar 20, 2023 at 15:09


You must log in to answer this question.

Browse other questions tagged .