in reply to Improving SQL speed

You may look into using transactions, and only commit every N entries, or every M seconds, whichever is faster. You may find that slowness is largely caused by (implicit or explicit) commit for every insert.