Skip to content

Instantly share code, notes, and snippets.

@AdamNaj
Last active August 29, 2015 14:14
Show Gist options
  • Save AdamNaj/273458beb3f2b179a0b6 to your computer and use it in GitHub Desktop.
Save AdamNaj/273458beb3f2b179a0b6 to your computer and use it in GitHub Desktop.
Find-Item test scripts
Find-Item -Index sitecore_master_index `
-Criteria @{Filter = "StartsWith"; Field = "_fullpath"; Value = "/sitecore/system/modules/PowerShell/" } `
-First 1 |
select -expand "Fields"
$first = 10000
Write-Host "Scripts" -ForegroundColor Red
Measure-Command {
$measure = `
Find-Item `
-Index sitecore_master_index `
-Where 'Path.StartsWith(@0) and TemplateName = @1' `
-WhereValues "/sitecore/system/modules/PowerShell/", "PowerShell Script" `
-First $first |
Measure-Object
Write-Host "Dynamic: $($measure.Count) " -f Cyan -NoNewline
} | % { Write-Host "$($_.Milliseconds) ms" }
Measure-Command {
$measure = `
Find-Item `
-Index sitecore_master_index `
-Criteria @{Filter = "StartsWith"; Field = "_fullpath"; Value = "/sitecore/system/modules/PowerShell/"},
@{Filter = "Equals"; Field = "_templatename"; Value = "PowerShell Script"} `
-First $first |
Measure-Object
Write-Host "Criteria: $($measure.Count) " -f Cyan -NoNewline
} | % { Write-Host "$($_.Milliseconds) ms" }
Write-Host "Templates" -ForegroundColor Red
Measure-Command {
$measure = `
Find-Item `
-Index sitecore_master_index `
-Where 'TemplateName = @0 And Language=@1' `
-WhereValues "Template Field", "en" `
-First $first |
Measure-Object
Write-Host "Dynamic: $($measure.Count) " -f Cyan -NoNewline
} | % { Write-Host "$($_.Milliseconds) ms" }
Measure-Command {
$measure = `
Find-Item `
-Index sitecore_master_index `
-Criteria @{Filter = "Equals"; Field = "_templatename"; Value = "Template Field"; CaseSensitive = $true},
@{Filter = "Equals"; Field = "_language"; Value = "en"; CaseSensitive = $true} -first $first |
Measure-Object
Write-Host "Criteria $($measure.Count) " -f Cyan -NoNewline
} | % { Write-Host "$($_.Milliseconds) ms" }
Measure-Command {
$measure = `
Get-Item master:\ -Query 'fast:/sitecore//*[@@TemplateName="Template Field"]' |
Measure-Object
Write-Host "FastQuery $($measure.Count) " -f Cyan -NoNewline
} | % { Write-Host "$($_.Milliseconds) ms" }
Measure-Command {
$measure = `
Get-ChildItem master:\templates\ -recurse |
?{ $_.TemplateID -eq "{455A3E98-A627-4B40-8035-E683A0331AC7}" } |
Measure-Object
Write-Host "Children $($measure.Count) " -f Cyan -NoNewline
} | % { Write-Host "$($_.Milliseconds) ms" }
Section Approach Items returned Time taken
Scripts Dynamic 129 59 ms
Scripts Criteria 129 42 ms
Templates Dynamic 1167 355 ms
Templates Criteria 1167 322 ms
Templates FastQuery 990 580 ms
Templates Children 1014 337 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment