Fix slow sql query in item import