A system comprising: a control node configured to: generate a statistical query task directed acyclic graph that is associated with a data set; and assign a plurality of distributed queries, respectively associated with distributions of the data set and generated by dividing the statistical query task directed acyclic graph, to a plurality of processing nodes; the plurality of processing nodes at least partially in parallel for each distribution respectively, are configured to: generate by each of the plurality of processing nodes, data structures that respectively store first data associated with respective frequencies of values, second data associated with a number of distinct values, and third data associated with a random sampling of the values; construct, by each of the plurality of processing nodes, a histogram respectively based on the first data, the second data, and the third data of distributions processed by said each of the plurality of processing nodes; transmit, by each of the plurality of processing nodes to each other processing node, a count value indicative of a number of rows in respective distributions processed by each of the plurality of processing nodes; merge, by a first processing node of the plurality of processing nodes, the first data generated by the plurality of processing nodes, and the second data generated by the plurality of processing nodes; and merge, by a second processing node of the plurality of processing nodes, the third data generated by the plurality of processing nodes; and a third processing node of the plurality of processing nodes configured to construct a global histogram of the data set based on the merged first data, the merged second data, and the merged third data. a control node configured to: generate a statistical query task directed acyclic graph that is associated with a data set; and assign a plurality of distributed queries, respectively associated with distributions of the data set and generated by dividing the statistical query task directed acyclic graph, to a plurality of processing nodes; generate a statistical query task directed acyclic graph that is associated with a data set; and assign a plurality of distributed queries, respectively associated with distributions of the data set and generated by dividing the statistical query task directed acyclic graph, to a plurality of processing nodes; the plurality of processing nodes at least partially in parallel for each distribution respectively, are configured to: generate by each of the plurality of processing nodes, data structures that respectively store first data associated with respective frequencies of values, second data associated with a number of distinct values, and third data associated with a random sampling of the values; construct, by each of the plurality of processing nodes, a histogram respectively based on the first data, the second data, and the third data of distributions processed by said each of the plurality of processing nodes; transmit, by each of the plurality of processing nodes to each other processing node, a count value indicative of a number of rows in respective distributions processed by each of the plurality of processing nodes; merge, by a first processing node of the plurality of processing nodes, the first data generated by the plurality of processing nodes, and the second data generated by the plurality of processing nodes; and merge, by a second processing node of the plurality of processing nodes, the third data generated by the plurality of processing nodes; and generate by each of the plurality of processing nodes, data structures that respectively store first data associated with respective frequencies of values, second data associated with a number of distinct values, and third data associated with a random sampling of the values; construct, by each of the plurality of processing nodes, a histogram respectively based on the first data, the second data, and the third data of distributions processed by said each of the plurality of processing nodes; transmit, by each of the plurality of processing nodes to each other processing node, a count value indicative of a number of rows in respective distributions processed by each of the plurality of processing nodes; merge, by a first processing node of the plurality of processing nodes, the first data generated by the plurality of processing nodes, and the second data generated by the plurality of processing nodes; and merge, by a second processing node of the plurality of processing nodes, the third data generated by the plurality of processing nodes; and a third processing node of the plurality of processing nodes configured to construct a global histogram of the data set based on the merged first data, the merged second data, and the merged third data.