Lazy on-materialization self optimization