1. A method for use at a computer system, the computer system including one or more processors, the method for querying a table, the method comprising the one or more processors: accessing first statistics corresponding to a portion of a column in the table, the portion of the column distributed at a first database in accordance with a partitioning algorithm that defines how portions of the table are distributed across the first database and distributed across a second database, the first database at a first compute node and the second database at a second compute node; accessing second statistics corresponding to another portion of the column in the table, the other portion of the column distributed at the second database in accordance with the partitioning algorithm; merging the first statistics and the second statistics into global statistics for the column, the global statistics including global steps defined by step boundaries, including for each global step: calculating a number of occurrences of an upper boundary value by adding the number of occurrences of upper boundary values across the local statistics; and calculating a global average number of rows per distinct value for the global step, including: determining an average compute node frequency of distinct values within the step boundaries; calculating the probability that a particular distinct value appears at a particular compute node based on the partitioning algorithm; and determining a global average row frequency for the global step based on the determined average compute node observed frequency and the calculated probability; and optimizing the query for querying the table based on the global statistics for the column; and executing the optimized query across the first database and the second database to retrieve data from the table.