Close statements
Convert UPDATE into INSERT

This seems to cut the time down from 14s to 10s
Use prepared statements