PostgreSQL 中的簇索引和非簇索引
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27978157/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cluster and Non cluster index in PostgreSQL
提问by MAK
I'm using PostgreSQL 9.3 version to create database.
我正在使用 PostgreSQL 9.3 版本来创建数据库。
I have the following table test with some columns list.
我有一些列列表的下表测试。
create table test
(
cola varchar(10),
colb varchar(10),
colc varchar(10),
cold varchar(10)
);
Now I want to create a indexs on some columns.
现在我想在某些列上创建索引。
For example:
例如:
I want to create clustered index for columns cola
and colb
.
我想为列cola
和colb
.
And I want to create non clustered index for columns colc
and cold
.
我想为列colc
和cold
.
As I referred thisAnd this,I come to know that there is no clustered and non clustered index in PostgreSQL.
正如我提到的this和this,我开始知道PostgreSQL中没有聚集索引和非聚集索引。
My Question: What type of index I can use instead of clustered and non clustered index in PostgreSQL,Which does the same job as clustered and non clustered indexes does?
我的问题:我可以使用什么类型的索引来代替 PostgreSQL 中的聚集索引和非聚集索引,哪个与聚集索引和非聚集索引的工作相同?
回答by Markus Winand
My Question: What type of index I can use instead of clustered and non clustered index in PostgreSQL,Which does the same job as clustered and non clustered indexes does?
我的问题:我可以使用什么类型的索引来代替 PostgreSQL 中的聚集索引和非聚集索引,哪个与聚集索引和非聚集索引的工作相同?
PostgreSQL doesn't have the concept of clustered indexes at all. Instead, all tables are heap tables and all indexes are non-clustered indexes.
PostgreSQL 根本没有聚集索引的概念。相反,所有表都是堆表,所有索引都是非聚集索引。
Just create a non-clustered index when you'd usually create a clustered index.
当您通常创建聚集索引时,只需创建一个非聚集索引。
More details:
更多细节:
- http://use-the-index-luke.com/sql/clustering/index-organized-clustered-index
You might want to read the whole chapterto get proper understanding of these concepts.