1. A method comprising: generating one or more individual sets of statistics for each of one or more intermediate relations of a workflow, wherein said one or more intermediate relations comprise results of one or more stages of any plan of the workflow, and wherein each individual set of statistics computes input cardinality of a corresponding intermediate relation of the workflow; determining which statistics from the one or more individual sets of statistics to designate as a global set of statistics for the workflow, wherein said global set of statistics comprises at least one of the one or more individual sets of statistics for each of the one or more intermediate relations, and wherein said determining which statistics to designate as the global set of statistics comprises: computing a cost for collecting each individual set of statistic of the one or more individual sets of statistics based on corresponding computed input cardinality of the individual set of statistic; wherein the at least one of the one or more individual sets of statistics for each of the one or more intermediate relations comprised in the global set of statistics for the workflow has a lowest computed cost; instrumenting multiple distinct plans of the workflow to be executed, wherein said instrumenting comprises identifying each of the multiple distinct plans by identifying multiple distinct orderings of multiple distinct operators of the workflow, wherein the multiple distinct operators comprise two or more of (i) a select operator, (ii) a project operator, (iii) a join operator, (iv) a group-by operator, (v) a transformation operator, (vi) a filter operator, and (vii) a user-defined function operator; executing each of the instrumented multiple distinct plans to collect statistics for the global set of statistics for each of the executed multiple distinct plans; and determining one of the multiple plans of the workflow with a lowest cost by comparing a cost of each of the multiple plans of the workflow, wherein the cost of each of the multiple plans is derived from (a) the global set of statistics for each of the multiple distinct plans and (b) a cost model that estimates the cost based on (i) cardinalities of input relations, (ii) central processing unit (CPU) and disk-access speeds, and (iii) memory availability, and wherein said determining comprises adhering to one or more constrained resources associated with the workflow, wherein said one or more constrained resources comprise one or more memory constraints comprising at least a limit on total memory available for computing statistics; using the determined one of the multiple plans with the lowest cost for each of one or more subsequent runs of the workflow; wherein the steps are carried out by a computer device.