We consider cooperative spectrum sensing in which multiple cognitive radios collaboratively detect the spectrum holes through energy detection and investigate the optimality of cooperative spectrum sensing with an aim to optimize the detection performance in an efficient and implementable way. We derive the optimal voting rule for any detector applied to cooperative spectrum sensing. We also optimize the detection threshold when energy detection is employed. Finally, we propose a fast spectrum sensing algorithm for a large network which requires fewer than the total number of cognitive radios in cooperative spectrum sensing while satisfying a given error bound.