Fast Query

Fast Query

Sitecore Fast Query

  • Alternative to Sitecore Query and the Lucene index
  • Requires only a single line of code
  • Faster than Sitecore Query because queries are executed by the SQL engine, not Sitecore or .NET

Query Memory Consumption

  • Sitecore Query loads every item that it touches into memory (cache)
  • Fast Query uses less memory because it only loads the result set

Fast Query Limitations

  • Only supports a small subset of attributes and axes of Sitecore Query
  • Only supports being used in custom .NET code, not XSLT
  • Standard values not supported
  • Functions, Operators and Subqueries are not supported
  • Only returns items from the SqlDataProvider

Lucene Index

  • Fastest method for querying Sitecore content
  • Supports complex searches, including free text searches

Fast Query Guidelines

  • Fast Query works best when template fields are shared instead of versioned
  • Use the Sitecore Search API instead of Fast Query so that indexes are used rather than the content structure

Fast Query C# Web Control Code

Sitecore.Data.Database db = Sitecore.Context.Database;
Sitecore.Data.Items.Item item = db.GetItem("/sitecore/content/home/marketers");
if (item == null) return;

Sitecore.Data.Items.Item[] items = Sitecore.Context.Database.SelectItems("fast:/sitecore/content/home/marketers//*[@@templatename='TIC-PermBuilderPage']");
if (items == null) return;

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold; width:100%; clear:both");
output.Write("C# Web Control Real-time Output");

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-size:x-small; width:100%; clear:both");
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold");
//using : for colon and   for space
output.Write("{0}: {1}", "Parent Item", item.DisplayName);
output.RenderEndTag(); //P

foreach (Sitecore.Data.Items.Item child in items)
    output.Write("{0}: {1}", "Filtered Descendant", child.DisplayName);
    output.RenderEndTag(); //Li

output.RenderEndTag(); //Ol
output.RenderEndTag(); //Div

Fast Query C# Web Control Output

Parent Item: Marketers

  1. Filtered Descendant: Site Health
  2. Filtered Descendant: Campaigns
  3. Filtered Descendant: Content Profiling
  4. Filtered Descendant: Engagement Automation
  5. Filtered Descendant: Multivariate Tests
  6. Filtered Descendant: Sales Enablement
  7. Filtered Descendant: Social Networking
  8. Filtered Descendant: Personalization
  9. Filtered Descendant: Web Forms
  10. Filtered Descendant: Conversions
  11. Filtered Descendant: DMS Concepts
  12. Filtered Descendant: Visitor Segmentation
  13. Filtered Descendant: Traffic Analysis
  14. Filtered Descendant: Visitor Experience
  15. Filtered Descendant: Engagement Analytics
  16. Filtered Descendant: SEO