Next: , Previous: Warning Messages, Up: Invoking find


8.1.3 Optimisation Options

The ‘-Olevel’ option sets find's optimisation level to level. The default optimisation level is 1.

At certain optimisation levels, find reorders tests to speed up execution while preserving the overall effect; that is, predicates with side effects are not reordered relative to each other. The optimisations performed at each optimisation level are as follows.

0
Currently equivalent to optimisation level 1.
1
This is the default optimisation level and corresponds to the traditional behaviour. Expressions are reordered so that tests based only on the names of files (for example‘ -name’ and ‘-regex’) are performed first.
2
Any ‘-type’ or ‘-xtype’ tests are performed after any tests based only on the names of files, but before any tests that require information from the inode. On many modern versions of Unix, file types are returned by readdir() and so these predicates are faster to evaluate than predicates which need to stat the file first.

If you use the ‘-fstype FOO’ predicate and specify a filsystem type ‘FOO’ which is not known (that is, present in /etc/mtab) at the time find starts, that predicate is equivalent to ‘-false’.

3
At this optimisation level, the full cost-based query optimiser is enabled. The order of tests is modified so that cheap (i.e., fast) tests are performed first and more expensive ones are performed later, if necessary. Within each cost band, predicates are evaluated earlier or later according to whether they are likely to succeed or not. For ‘-o’, predicates which are likely to succeed are evaluated earlier, and for ‘-a’, predicates which are likely to fail are evaluated earlier.