Insert/Update DB table when making new post or update older one

Add the following right at the top of your function code, it will exit the function if it’s doing an auto save:

if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return;

You may find you also need to use the following aswell:

if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
return;