Visualforce Error: System.UnexpectedException: SOQL statements cannot query more than 20 different child types.

  • 1
  • Problem
  • Updated 4 years ago
  • Solved
New error trying to display/preview a page. This was not happening when I was working on it last Friday. 
Photo of Rachel King

Rachel King

  • 80 Points 75 badge 2x thumb
  • concerned

Posted 4 years ago

  • 1
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
Check out this thread: https://developer.salesforce.com/forums/ForumsMain?id=906F000000090dFIAQ. It seems like you have a model where you're query is not selective enough. You should use conditions to make the query as efficient and targeted as possible. Do you have a lot of models on the page? What object s are they on? What conditions do you have on the models? If you give some more information I can try to help.
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,014 Points 20k badge 2x thumb
Sounds like one of your Models has a lot of Child Relationships in it --- do you know if is this true? Did you add additional Child Relationships since last week, or was the page unchanged since last week?