Page History
...
The server configuration "optimize for ad hoc workloads" changes the behavior of the instance such that the first time a statement is run, a very small version of the plan called a stub is cached, and it is only once the query is executed a second time that the full execution plan is stored. While there are special cases where this option may have a negative impact, for most environments turning this option on will have a positive or neutral effect on the server.
...