We all know that Caml is faster than using linq, since linq internally gets translated to caml.

But can anyone explain how caml is best to do sharepoint queries or how it is fast or what makes it fast ? I dont want comparison between linq and caml, its clear to me.

For me, caml is some string(xml) which must be read/parsed and then again some sql query is called in background to get the results. Can't there be any other best option to do query ?

3 Answers 3


CAML is simply the fastest (if you write efficient CAML queries that is) for the obvious reason that there is no other query language for SharePoint.

  • Linq to SP uses CAML internally
  • The API methods does not convert to CAML and queries for the whole "collection" of objects
  • The CAML query is converted to T-SQL internally by SP and queries the content databases (and you are not allowed to do that)

There is no other way to access SharePoint data, period. (Except by using the Search Index which is way faster - but not complete in terms of data).

  • 3
    no other SUPPORTED way to access SharePoint data. wont deny that I've written a few T-sql nolock queries against my content db.
    – 1c1cle
    Jul 10, 2012 at 17:29
  • search API (keyword queries)? :) Jul 10, 2012 at 17:54
  • oh I see you have mentioned search, sorry Wictor Jul 10, 2012 at 17:54

CAML deals with only those items which matches the filter criteria and they will retrived from database. Where Linq has the entire collection to manage with. Linq will Translate the query to CAML and send it to database and then fetch results. Hence CAML does not require the extra step.

  • 1
    "Where Linq has the entire collection to manage with.". This is not true. The Linq Provider will convert, what it can, into a CAML in order to retrieve only matching items. It won't read the whold collection. Please note I use "what it can" sentence. That means that you have to be very very careful when using Linq to SharePoint. You should check you queries to ensure the maximum of operations are performed in CAML by the provider. The best way to avoid such issues is to avoid Linq. The second way is the redirect the DataContext.Log to the debug window, and check which query are executed.
    – Steve B
    Jul 10, 2012 at 11:56
  • that means Linq converts parts of the query into CAML?
    – sharmila
    Jul 10, 2012 at 12:14
  • Yes. So does all Linq2xxx (sql, entities, sharepoint, etc.). If you want to learn more, google on Linq query provider. This is a great feature of .Net, but knowing how it works backstage is important to avoid performance issues.
    – Steve B
    Jul 10, 2012 at 12:21
  • But still this doesn't answer my question : how/what makes CAML fast ? I dont want linq vs caml. Isn't there overload to parse that CAML string ?? Jul 10, 2012 at 13:30

actually the statement is not true for all cases. actually in most cases it is possible to write Linq2SP queries as efficient as CAML could be, but you usually have to put some efforts to track generated CAML

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.