locked
Number of link entities in query exceeded maximum limit." RRS feed

  • Question

  • We are using Fetch XML to retrieve a set of data from CRM.  The Fetch XML statement contains a lot of joins around 14.  However when we run the Fetch XML Query we get the following error

     

    Number of link entities in query exceeded maximum limit."

    Upon further research I came across the following, but unfortunately there is no solution to this.

    http://social.microsoft.com/Forums/en/crm/thread/b3978065-7215-4643-a9e8-e9b388f44814

    Can someone point me in the direction of a solution or a workaround to this, currently the only workaround that comes into mind is to use a SP in the database itself instead of the Fetch XML.  That being said is querying the CRM database directly supported?

    Tuesday, June 21, 2011 2:30 PM

All replies

  • I would suggest refactoring your fetch XML query to reduce the number of joins, it's never a good idea to have too many joins in a single CRM query, as doing so will introduce significant performance overhead.
    Daniel Cai | http://danielcai.blogspot.com
    Tuesday, June 21, 2011 3:14 PM
  • Thanks Daniel, but that is not a solution, we have the joins because we need them, the business logic is too complicated to reduce the join.
    Wednesday, June 22, 2011 7:56 AM
  • The only solution I have for the moment is to use the views in the CRM database to generate the required output. I have to write a custom sp to work with the views. Any ideas anyone?
    Wednesday, June 22, 2011 8:23 AM
  • Hi John,

    It depends if you are executing your code in JScript then you might consider refactoring or writing a SOAP webservice that will execute the code on server end and pass results (even can create a new entity pass attrobutes in it and process execution on server side in a plugin and then get results)

    Adding a view in CRM 2011 database is not recomended and supported if you still want to add a view into CRM database then you have to create it manually in CRM database. If your are using your code in ASP.net or other applicaiton then you may consider using LINQ or QueryExpression etc

    I hope this helps.


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Wednesday, June 22, 2011 9:49 AM
  • John, I was well aware in the first place that my recommendation may not be taken as a solution. No worries at all.

    I am relatively sure this limitation is imposed by CRM team intentionally for performance reason. My sense is, for each joining entity involved, CRM platform needs to inject security check based on the user account and its security roles, which adds up the number of joins in an exponential scale. That's the reason why the limitation exists in the first place. Using LINQ and Query Expression wouldn't change the situtation in my sense, but you may give them a try.


    Daniel Cai | http://danielcai.blogspot.com
    Wednesday, June 22, 2011 3:08 PM
  • Hi,

    Yes this is an intentional product restriction. We cannot use more than 10 link entities and it will not work with any query model - Fetch, QE or Linq . We'll try to get this information to the SDK help.


    Nabanita Majumdar
    Thursday, January 26, 2012 11:57 PM