How to prevent WordPress from retrieving data for the last 10 posts in the database?

The reason is you are visiting the home page and it contains the WordPress Loop like below to query 10 recent posts.

<?php
if ( have_posts() ) :
    while ( have_posts() ) : the_post();
        // Your loop code
    endwhile;
else :
    // not found template
endif;
?>

The number of posts can be managed from settings->reading->Blog pages show at most. from WordPress dashboard.
There you will see 10 posts selected in the value. if you want to display 5 posts then change this value.

if you want to remove this query from home page then edit index.php, frontpage.php or home.php file depending upon your theme. Recommended way is to create a page template and do your thing there. how to create page template in WordPress

tech