Version: 1.8.4 stable using MySQL

I'm syncing my CMDB system with Zabbix using API mode. On first charge, I need create 10000 hosts and this process was taking too long.

Looking into MySQL's process list, I got this query:

Code:
SELECT max(ht.hostid) as hostid,
...