A colleague recently asked me for advice on an issue he had whereby a fast query was not returning all the items from a particular folder in the content tree.
Now leave aside for a minute the fact that fast query was being used dubiously (it was an ancient legacy part of the system with no remit given to refactor right now).
The query in question was a simple descendant folder search based on the template GUID:
The items in question were all published and present in the web database
A manual SQL query of the Items table in the web database brought back the items with no obvious oddities on the records.
We duplicated the existing missing item, published it, and that too was not brought back in the query
This rang a bell – I remembered reading some time ago about odd behaviour when the Descendants table was corrupted or in an inconsistent state.
According to the documentation if the FastQueryDescendantsDisabled setting has ever been changed you need to rebuild the Descendants table.
To do this, navigate to the Sitecore Control Panel -> Databases -> Clean Up Database and run the Clean Up Database wizard.
And whadda ya know – all results were now being returned. 😉
Note: This command actually does more than rebuild the Descendants table, it also cleans up invalid language data, orphaned fields and items and more. See this nice StackExchange post for the full list of tasks that get carried out.
Now to convince the powers that be, that fast needs to be killed 😛