我有一个包含三个整数列id和a的表b。 我想获取所有记录,其中a或b匹配指定参数排序id:
id
a
b
select id, a, b from t where a=x or b=x order by id
请注意,和 的x值相同。ab
x
这里最合适的索引是什么?
更新:我们总是在列和中寻找相同的值,这一事实有什么用处吗?我们可以为此创建一个表达式索引吗?ab
postgresql performance index postgresql-performance
index ×1
performance ×1
postgresql ×1
postgresql-performance ×1