Go to gmail.com and in your settings there look for the IMAP tab. Make sure you have enabled IMAP and used Gmails provided settings for configuring Apple Mail.
Then in that same IMAP settings section on gmail.com use the dropdown at the bottom of my screenshot to limit the amount of IMAP messages synced.
View attachment 604220