The issue is that the query plan can’t take into account variables like $1
when selecting an index. For example, if the index has a predicate such as WHERE organization = "myorganization"
then you must supply it on the query in that syntax, not using a $1
parameter, or it can’t use the index. This is because it has no way to know at the planning stage that the variable will match that index, so it selects a different index instead.