小编Sam*_*gri的帖子

在 Postgres 中创建索引的正确列顺序

Address考虑具有两列的表textCityState。我将实现以下查询:

select * from address where city = $1 and state = $2;
Run Code Online (Sandbox Code Playgroud)

为了能够通过索引搜索,我将创建一个索引:

create index address_city_state on address(city,state);
Run Code Online (Sandbox Code Playgroud)

问题是,考虑到城市值比州值变化更大,在创建索引时设置列的顺序(首先是城市而不是州)对查询性能的影响还是以任何其他方式?

sql postgresql indexing

6
推荐指数
1
解决办法
5145
查看次数

标签 统计

indexing ×1

postgresql ×1

sql ×1