- Home
- Technical Library
- Partners
- Blog
- Ideas
- Code Share
-
Discussion Boards
- Announcements
- General Development
- New to Cloud
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules Discussion
- Security
- Force.com Sites
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby Development
- Adobe Flash Builder for Force.com
- Desktop Integration
- Apple, Mac and OS X
- VB and Office Development
- Excel Connector
- AJAX Toolkit & S-controls
- Force.com Builder & Native Apps
- AppExchange Directory & Packaging
- Force.com Labs Projects
- Open Source
- Jobs Board - Developer
- Job Board - Administrators
- More
Discussions
- Announcements
- General Development
- New to Cloud Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules Discussion
- Security
- Force.com Sites
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby Development
- Adobe Flash Builder for Force.com
- Desktop Integration
- Apple, Mac and OS X
- VB and Office Development
- Excel Connector
- AJAX Toolkit & S-controls
- Force.com Builder & Native Apps
- AppExchange Directory & Packaging
- Force.com Labs Projects
- Open Source
- Jobs Board - Developers
- Jobs Board - Administrators
- Force.com Discussion Boards
- :
- Developer Boards
- :
- General Development
- :
- Re: What condition triggers a QUERY_TOO_COMPLICATE...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
What condition triggers a QUERY_TOO_ COMPLICATE D error?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-21-2008 03:05 PM
Lately I've been getting this error (QUERY_TOO_COMPLICATED) but the API documentation doesn't say exactly what makes the query too complicated.
Is there a hard number of calculated fields (or relationship queries) that can be included in a single Retrieve call? Does it depend on the complexity of the formulas within the calculated fields?
If anyone can shed more details about what contributes to this error, I would be really grateful.
Mike
Solved! Go to Solution.
Re: What condition triggers a QUERY_TOO_ COMPLICATE D error?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-24-2008 05:28 PM
I've done a bit of internal research, and there is no easy way to determine when you are crossing the line into the realm of too complex. I recommend that you call customer support, who can help you understand how this applies to your particular situation and what they might be able to do to help alleviate it.
Hope this helps.
Developer Evangelist
Allons danser
Re: What condition triggers a QUERY_TOO_ COMPLICATE D error?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-24-2009 10:01 AM
Can we reopen this issue? I've encountered similar problems and because of the type of app I'm supporting, I can't look at the query itself (at this time).
I've seen that an "order by" is limited to 32 fields.
Is there a limit to the number of fields you can include in a select itself?
Re: What condition triggers a QUERY_TOO_ COMPLICATE D error?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-24-2009 02:17 PM
Re: What condition triggers a QUERY_TOO_ COMPLICATE D error?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-10-2009 03:54 PM
If calculated fields mean formula fields; then formula fields generate SQL expressions based on the formula expression, which can get pretty large if the formula is complicated, selecting more complex formula fields will increase the chances of hitting the Oracle 64k limit. Formulas are in itself complex expressions and hence compile to some non-trivial SQL. The SQL size per formula field is limited to 5k.
Currently it is possible for the SQL size of formula fields to go over the 5k limit but that may change in a future release to go back to 5k.
Re: What condition triggers a QUERY_TOO_ COMPLICATE D error?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-10-2009 04:03 PM
I've retrieved more than 500 fields at once, so maybe the 500 field limit only applies to the query call.
This is the first I've heard about the cause of this issue being an Oracle limitation; has this been documented anywhere?
Re: What condition triggers a QUERY_TOO_ COMPLICATE D error?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-11-2009 03:17 AM
No it not currently documented. This information was discovered from an open case with Support.
When were you able to query more than 500 fields from an object? Did it include related fields?
Re: What condition triggers a QUERY_TOO_ COMPLICATE D error?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-11-2009 08:52 AM
Just to avoid confusion, it was technically a retrieve() and not a query() as far as the API call goes. I'm not positive that I had more than 500 fields but my recollection is that I had about 520. I was debugging this QUERY_TOO_COMPLICATED issue so I set up a developer account with hundreds of custom fields and retrieve()'d them all. I don't think any of them were related fields.
I'll try setting something up with a large number of related fields and see if I can figure out where the breaking point is.
This is such an easy issue to avoid, though -- it seems incredible that the Salesforce backend can't be bothered to split up a list of fields into chunks that can fit inside Oracle's query limit. I'm doing that already to fit inside the SF API's 10,000 char limit: I'm splitting very large field lists for retrieve() into multiple retrieve calls that are then re-assembled. It's not hard.
Re: What condition triggers a QUERY_TOO_ COMPLICATE D error?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-12-2009 11:31 AM
I agree its not difficult to split up the query to avoid the 64k limit however performance issues need to be considered. In addition to governor limits in an Apex environment. Having a user make one query call where the backend needs to make 2 or more calls doesn't scale well especially in bulk processes.
Re: What condition triggers a QUERY_TOO_ COMPLICATE D error?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-12-2009 11:51 AM
True, but given that we have no idea what will or will not hit the QUERY_TOO_COMPLICATED limit, there aren't many options. At least if we had a metric that we could use to determine the threshold, we could work around it on the client side.

