in reply to Optimize sqlite prepared statement

The error is telling you how to fix it.

(either destroy statement handles or call finish on them before disconnecting)

Just add the "finish" line and the warning will go away-

close(LOGFILE); $sth->finish();