Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Sitecore use Fast Query automatically?

Tags:

sitecore

According to Sitecore Data Definition Reference, version 6.4, section 4.3.1:

Sitecore processes queries using the fasted technology possible. This could be either the SQL database, if the data provider supports the requested query, or in the Sitecore data manager.

If this is so, is there any benefit to using the "fast:" syntax? With what release did automatic technology selection get introduced?

Update I think I figured it out. Reqular Sitecore queries can only use SQL Server if they do not have predicates. Fast Query allows simple predicates (e.g. *[@somefield='somevalue']) while still making use of SQL Server.

From Sitecore CMS 6.4 Data Definition Reference (Section 4.3.4):

The SQL Server data provider does not support predicates (the portion of the search string enclosed in square brackets: [@IsHidden != '1']).

From Sitecore CMS 6 Using Sitecore Fast Query (Section 4.2):

This section describes the predicates that are available in Sitecore Fast Query. Predicates are always embedded in square brackets.

Example: fast:/sitecore/content/Home/*[@Title = 'Welcome to Sitecore']  

Result: returns the items that have the value of the 'Title' field set to 'Welcome to Sitecore'. The search is performed in the children of the Home Item.

like image 662
Dan Solovay Avatar asked May 01 '11 03:05

Dan Solovay


1 Answers

There are several different approaches to querying items from Sitecore:

  • Sitecore Query
  • Fast Query
  • Lucene

Each approach has its own pros and cons. For example, Sitecore Query and Fast Query both have a limit to the number of items they can return. This limit is the Query.MaxItems setting in the web.config. Lucene on the other hand is its own beast and uses search indexes stored on disk to access items.

Sitecore query is the most flexible in terms of filtering items right in the query, however the more complex your query is, the longer it will take to run (that's a generalization). Its often easier to make a more generic query then use .NET to filter it, like LINQ. Fast query goes straight to the database to query and thus has limit on the filtering. It runs faster but you can't be as granular with what you want to check in your query.

Lucene is another approach as it uses search indexes to query content and filter. This requires additional configuration work up front and maintenance of the search index.

This can help you decide which approach to take:

  • 100 items or less: Sitecore Query
  • 1000 items or less: Fast Query
  • 1000+ items: Lucene

I've also previously written blog post on this same topic:

  • Options For Querying Items From Sitecore
like image 98
Mark Ursino Avatar answered Nov 10 '22 22:11

Mark Ursino