I'm implementing a full text search on list contents.

Is it more efficient to fire a SPSiteDataQuery on every request with a dynamically built CAML-Query, to filter the items?

Or is it better to fetch the data once, store it in e.g. HttpRuntime.Cache and filter the data somehow in code (maybe via DataTable.Select or something...didn't try this).

What do you think?

  • How much data are we talking? Jan 10 '12 at 20:05
  • about 200 - 300 items stored in 2 lists
    – Tom Bola
    Jan 10 '12 at 22:43
  • hmm, 200-300 items in 2 lists. Do they have (multi-)lookup fields?
    – Bas Lijten
    Jan 11 '12 at 8:40
  • No. The items are in the standard pages list (PublishingPages) and a custom document library (Documents with some additional metadata). Data of the items from both lists will be displayed in one result list.
    – Tom Bola
    Jan 11 '12 at 8:48

I would go with the first option, as the SPSiteDataQuery already makes use of caching, if you use it correctly. It's fast as hell ;)

check my blogpost about it: http://bloggingabout.net/blogs/bas/archive/2009/03/27/using-the-crosslistqueryinfo-and-crosslistquerycache.aspx

Steve peschka wrote a document on it in the past: http://go.microsoft.com/fwlink/?LinkId=95450&clcid=0x409

MSDN: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsitedataquery.aspx

  • In your blog you're talking about CrossListQueryCache. When the query changes (which does, because the CAML is created dynamically to filter the items), does it clear the cache and fetch new results? The document from Steve Peschka doesn't help because it is about SPQuery and PortalSiteMapProvider.
    – Tom Bola
    Jan 11 '12 at 8:13
  • no, the items are cached, not the query with its items.
    – Bas Lijten
    Jan 22 '12 at 19:07
  • so then CrossListQueryCache isn't capable for a full text search. If the query changes there MUST be only the new requested items.
    – Tom Bola
    Jan 25 '12 at 16:14
  • Is using search an option, then?!
    – Bas Lijten
    Jan 25 '12 at 17:12
  • No, unfortunately that's not an option. So I'll stick with an SPSiteDataQuery on every request.
    – Tom Bola
    Jan 25 '12 at 19:33

If you want SPSiteDataQuery functionality along with caching, better to use CrossListQueryCache and CrossListQueryInfo classes.

Check here for excellent details : http://extreme-sharepoint.com/2012/07/17/data-access-via-caml-queries/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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