We are using application (which is quite optimized, but not in this particular case) which stores posts in various categories.
The category field contains comma-separated list of category-ids and so the select query looks like this:
which of course can’t use any indexes.
Is it somehow possible to optimize/rewrite this query without changing the table structure? I know the best would be to have special table with multiple rows of post_id+categ_id, but that would require a lot of work.