Efficient Algorithms for Querying Large and Uncertain Data