Inserting new rows into an existing table
Before I continue, the following must be said:

Stop using mysql_query.

Seriously.  There have been very good replacements for going-on a decade now.  And considering this code does not appear to escape anything at all, you'd do well to learn to use parameterized queries so that it doesn't have to.



With all that said, though, the SQL might not even be necessary.  Is there a good reason you're not using wp_insert_post to, well, insert a post?  Looks like it lets you set everything you want to set, and then some.  It also returns the post ID, so you don't even have to touch the database directly to get it.

It sounds like the problem is not SQL or WordPress, really.  This code should not be as slow as you're describing.  If you have a DB server that's not your web server (which is generally the case in shared hosting and such), there will naturally be a bit of slowdown.  Generally not that much delay, though, unless the DB is hosted in a totally different place (ie: not from your web hosting company).  That, and the possibility that the server (DB or web server, either one) is simply overloaded, are more likely possibilities.