Address考虑具有两列的表text,City和State。我将实现以下查询:
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)
问题是,考虑到城市值比州值变化更大,在创建索引时设置列的顺序(首先是城市而不是州)对查询性能的影响还是以任何其他方式?