One of the fun things about machine learning is you have large datasets. A naive algorithm often isn't fast enough and forces optimisation.