I have a int[]
column, category_ids
, which has a cardinality of 5.
I have users which look for products that match certain category_ids
, and I'm currently returning results based on intersection between the ids they request and ids that match in category_ids
. Currently we have only 14 categories, but soon will be adding a lot more (~40). So, if a user wants to find 38/40 categories, that seems like it will be hairy.
I'm trying to learn more about arrays, but completely lost on indexing for this type of querying. How can I improve performance for this kind of query?
Basic high level example would be find me products that match category_ids [1..35], and finding it via array overlaps user_requested_category_ids && my_table.category_ids