Use SQL more intelligently to speed up the creation on the system