As we know, it is possible to limit post indexer query results by a sort term, for example by a tag or category ID. We also know that the limitation must be done via MySQL's LIKE function, which unfortunately, in the most of the cases, leads to very poor performance, especially if there is a lot of posts in the post indexer table.
So, my suggestion is that we should have a separate table for sort terms. The table could consist of the following columns: post_id | sort_term_type (category, tag, own type) | sort_term_value
Then, the limitation could be made for example as follows
SELECT * wp_site_posts.post_id, wp_site_sort_terms.post.id, wp_site_sort_terms.sort_term_type LEFT JOIN wp_site_posts ON wp_site_posts.post_id = wp_site_sort_terms.post.id WHERE wp_site_sort_terms.sort_term_type = 'tag'