Query Processing and Optimization for Database Stochastic Analytics