Using getOwnedTokenIds over getOwnedNFTs can have a significant performance boost. The trade-off here is that getOwnedTokenIds do not load the NFTs' metadata from IPFS.
This trick is particularly useful when you only need to know the token IDs of which a wallet owns, rather than the additional details of those NFTs.
If you want to get all the token ids from a large collection, using getNFTs can be costly since it makes a lot of extra requests internally to load the NFTs' metadata and their owner. You can refer to this article for a more performant approach.