  Nowadays, sampling-based Approximate Query Processing (AQP) is widely
regarded as a promising way to achieve interactivity in big data analytics. To
build such an AQP system, finding the minimal sample size for a query regarding
given error constraints in general, called Sample Size Optimization (SSO), is
an essential yet unsolved problem. Ideally, the goal of solving the SSO problem
is to achieve statistical accuracy, computational efficiency and broad
applicability all at the same time. Existing approaches either make idealistic
assumptions on the statistical properties of the query, or completely disregard
them. This may result in overemphasizing only one of the three goals while
neglect the others.
  To overcome these limitations, we first examine carefully the statistical
properties shared by common analytical queries. Then, based on the properties,
we propose a linear model describing the relationship between sample sizes and
the approximation errors of a query, which is called the error model. Then, we
propose a Model-guided Iterative Sample Selection (MISS) framework to solve the
SSO problem generally. Afterwards, based on the MISS framework, we propose a
concrete algorithm, called $L^2$Miss, to find optimal sample sizes under the
$L^2$ norm error metric. Moreover, we extend the $L^2$Miss algorithm to handle
other error metrics. Finally, we show theoretically and empirically that the
$L^2$Miss algorithm and its extensions achieve satisfactory accuracy and
efficiency for a considerably wide range of analytical queries.
