You can export optimization settings, such as set plan optgoal and set plan optcriteria, using set export_options on. Optimization settings are not local to the stored procedure; they apply to the entire user session.
By default, set export_options is enabled for login triggers.