Improve the performance of prefix_search