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

  • 1
  • Problem
  • Updated 5 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 5 years ago

  • 1
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,686 Points 5k badge 2x thumb
Check out this thread: 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

  • 53,784 Points 50k 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?