After searching the web over the night I found out that the problem is common and the same query I posted above is the culprit. According to WordPress Post Editor Performance, this is caused by Slow meta_form() database query
The safest solution he provided was a piece of code the function.php. I did that and I experience a great deal of changed. see code below:
/**
* Remove Ancient Custom Fields metabox from post editor
* because it uses a very slow query meta_key sort query
* so on sites with large postmeta tables it is super slow
* and is rarely useful anymore on any site
*/
function wpse391530_remove_post_custom_fields_metabox() {
foreach ( get_post_types( '', 'names' ) as $post_type ) {
remove_meta_box( 'postcustom' , $post_type , 'normal' );
}
}
add_action( 'admin_menu' , 'wpse391530_remove_post_custom_fields_metabox' );
You can read more about the solution on the article link posted above