A computer-implemented method, comprising: obtaining computer code that, when executed by at least one computer hardware processor, causes the at least one computer hardware processor to execute a database query, wherein the computer code comprises: a first set of one or more computer code portions each representing a data processing operation for reading in a respective input dataset; a second set of one or more computer code portions each representing a data processing operation for writing out a respective output dataset; and a third set of one or more computer code portions each representing a respective data processing operation; obtaining a first set of one or more processing layouts for one or more code portions in the first set of code portions, wherein for each code portion in the first set of one or more computer code portions, the obtaining of the processing layout for the code portion includes: dynamically determining a portion of the processing layout, including automatically determining the portion of the processing layout such that a degree of parallelism of the processing layout is serial, if the input dataset represented by the code portion is stored in a single storage location, or is N-way parallel, if the input dataset represented by the code portion is stored in a number of N, with N > 1, storage locations; obtaining a second set of one or more processing layouts for one or more code portions in the second set of code portions, wherein for each code portion in the second set of one or more computer code portions, the obtaining of the processing layout for the code portion includes: dynamically determining a portion of the processing layout, including automatically determining the portion of the processing layout such that a degree of parallelism of the processing layout is serial, if the output dataset represented by the code portion is stored in a single storage location, or is N-way parallel, if the output dataset represented by the code portion is stored in a number of N, with N > 1, storage locations; and determining a processing layout for each code portion in the third set of code portions based on the first set of processing layouts, the second set of processing layouts, and one or more layout determination rules including at least one rule for selecting among processing layouts having different degrees of parallelism. obtaining computer code that, when executed by at least one computer hardware processor, causes the at least one computer hardware processor to execute a database query, wherein the computer code comprises: a first set of one or more computer code portions each representing a data processing operation for reading in a respective input dataset; a second set of one or more computer code portions each representing a data processing operation for writing out a respective output dataset; and a third set of one or more computer code portions each representing a respective data processing operation; a first set of one or more computer code portions each representing a data processing operation for reading in a respective input dataset; a second set of one or more computer code portions each representing a data processing operation for writing out a respective output dataset; and a third set of one or more computer code portions each representing a respective data processing operation; obtaining a first set of one or more processing layouts for one or more code portions in the first set of code portions, wherein for each code portion in the first set of one or more computer code portions, the obtaining of the processing layout for the code portion includes: dynamically determining a portion of the processing layout, including automatically determining the portion of the processing layout such that a degree of parallelism of the processing layout is serial, if the input dataset represented by the code portion is stored in a single storage location, or is N-way parallel, if the input dataset represented by the code portion is stored in a number of N, with N > 1, storage locations; obtaining a second set of one or more processing layouts for one or more code portions in the second set of code portions, wherein for each code portion in the second set of one or more computer code portions, the obtaining of the processing layout for the code portion includes: dynamically determining a portion of the processing layout, including automatically determining the portion of the processing layout such that a degree of parallelism of the processing layout is serial, if the output dataset represented by the code portion is stored in a single storage location, or is N-way parallel, if the output dataset represented by the code portion is stored in a number of N, with N > 1, storage locations; and determining a processing layout for each code portion in the third set of code portions based on the first set of processing layouts, the second set of processing layouts, and one or more layout determination rules including at least one rule for selecting among processing layouts having different degrees of parallelism.