Some text messages are missing and never show in the content://sms provider URI since the Samsung S7 came out. I have noticed this between multiple Samsung devices (S6 and/o
It seems the messages that are missing are in fact not SMS, but RCS messages. These are not stored in the SMS Provider, and therefore will not be returned from any queries to it, though messaging apps on devices that support RCS are likely to display them all together seamlessly. This would explain why it appears that your query results are incomplete.
RCS (Rich Communication Services) is basically enhanced SMS/MMS, offering functionalities such as real-time one-to-one and group chat, video calling, content sharing, etc., in addition to regular ol' text messaging. Currently, there is no standard API in Android for this, though Google is reportedly in the process of adopting this as an eventual replacement for SMS/MMS. I could find no official word on how this will be integrated or deployed, however.
Not every carrier offers RCS, and those that do have dedicated, proprietary apps and APIs to handle it. These, of course, are going to be different for each carrier/manufacturer, and even the branding varies widely. Most call it joyn, whereas T-Mobile brands it as Advanced Messaging. As RCS becomes more commonplace, it should become more standardized, but supporting RCS in your app currently will require specialized components and setups.