在这篇文章中,我们将为您详细介绍PostgreSQL之INDEX索引详解的内容。此外,我们还会涉及一些关于c#中的PostgresqlNpgsql.PostgresException、centos7下
在这篇文章中,我们将为您详细介绍PostgreSQL之INDEX 索引详解的内容。此外,我们还会涉及一些关于c#中的Postgresql Npgsql.PostgresException、centos 7下源码编译安装php支持PostgreSQL postgresql手册 postgresql官网下载 postgresql视频教、Postgresql - Expression Indexes、PostgreSQL 11 新特性之覆盖索引(Covering Index)的知识,以帮助您更全面地了解这个主题。
本文目录一览:- PostgreSQL之INDEX 索引详解
- c#中的Postgresql Npgsql.PostgresException
- centos 7下源码编译安装php支持PostgreSQL postgresql手册 postgresql官网下载 postgresql视频教
- Postgresql - Expression Indexes
- PostgreSQL 11 新特性之覆盖索引(Covering Index)
PostgreSQL之INDEX 索引详解
项目招商找A5 快速获取精准代理名单
这篇文章主要介绍了PostgreSQL之INDEX 索引详解,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
之前总结了PostgreSQL的序列相关知识,今天总结下索引。
我们都知道,数据库索引最主要的作用是可以提高检索数据的速度,但是索引也不是越多越好。因为索引会增加数据库的存储空间,查询数据是要花较多的时间。
1、创建索引
SQL语句如下:
CREATE INDEX idx_commodity
ON commodity //表名
USING btree //用B树实现
(commodity_id); //作用的具体列
2、删除索引
1DROP index idx_commodity;
3、增加索引的优势:
创建索引可以大大提高系统的性能。
第一,最主要的原因是可以大大加快数据的检索速度;
第二,通过创建唯一性索引,可以保证数据库表中每一行数据的唯一性;
第三,可以加速表和表之间的连接,特别是在实现数据的参考完整性方面特别有意义;
第四,在使用分组和排序子句进行数据检索时,同样可以显著减少查询中分组和排序的时间;
第五,通过使用索引,可以在查询的过程中,使用优化隐藏器,提高系统的性能。
4、增加索引的劣势:
第一,创建索引和维护索引要花费时间,且随着数据量的增加时间也会增加;
第二,索引会占物理空间,除了数据表占数据空间之外,每一个索引还要占一定的物理空间;'
第三,当对表中的数据进行增加、删除和修改的时候,索引也要动态的维护,这样就降低了数据的维护速度。
5、索引的选择
一般来说,应该在这些列上创建索引:
第一、 在经常需要搜索的列上,可以加快搜索的速度;
第二、 在作为主键的列上,强制该列的唯一性和组织表中数据的排列结构;
第三、 在经常用在连接的列上,这些列主要是一些外键,可以加快连接的速度;
第四、 在经常需要根据范围进行搜索的列上创建索引,因为索引已经排序,其指定的范围是连续的;
第五、 在经常需要排序的列上创建索引,因为索引已经排序,这样查询可以利用索引的排序,加快排序查询时间;
第六、 在WHERE子句的列上面创建索引,加快条件的判断速度。
一般来说,不应该创建索引的的这些列具有下列特点:
第一,对于那些在查询中很少使用或者参考的列不应该创建索引。这是因为,既然这些列很少使用到,因此有索引或者无索引,并不能提高查询速度。相反,由于增加了索引,反而降低了系统的维护速度和增大了空间需求。
第二,对于那些只有很少数据值的列也不应该增加索引。这是因为,由于这些列的取值很少,在查询的结果中,结果集的数据行占了表中数据行的很大比例,即需要在表中搜索的数据行的比例很大。增加索引,并不能明显加快检索速度。
第三,对于那些定义为text, image和bit数据类型的列不应该增加索引。这是因为,这些列的数据量要么相当大,要么取值很少。
第四,当修改性能远远大于检索性能时,不应该创建索引。这是因为,修改性能和检索性能是互相矛盾的。当增加索引时,会提高检索性能,但是会降低修改性能。当减少索引时,会提高修改性能,降低检索性能。因此,当修改性能远远大于检索性能时,不应该创建索引。
补充:PostgreSQL索引分类及使用
1.索引方式
PostgreSQL数据库支持单列index,多列复合 index, 部分index, 唯一index, 表达式index,隐含 index, 和并发index。
2.索引方法
PostgreSQL 支持 B-tree, hash, GiST, and GIN index methods。
3.索引使用范围
1).B-tree
B-tree可以有效使用当一个查询包含等号(=)和范围操作符 (<, <=, >, >=, BETWEEN, and IN)。
2).hash
一个等号操作符(=),不适合范围操作符。
3).GiST
适用于自定义复杂类型,包括rtree_gist, btree_gist, intarray,tsearch, ltree 和 cube。
4).GIN
GIN比GiST占用多三倍多空间,适合复杂like,例如like ‘%ABC12%'。
4.索引使用注意事项
1).当一个表有很多行时,对一个表列进行索引是很重要的。
2).当检索数据时,应该选择一个好的备选列作为索引,外键,或者取最大最小值的键,列的选择性对索引有效性很重要。
3).为了更好的性能要移除不使用的索引,为了清除无法利用的行每隔一月重建所有索引。
4).如果有非常大量的数据,使用表分区索引。
5)当列中包含NULL值时,可以考虑建立一个不包含NULL的条件索引。
文章来源:
来源地址:https://www.jb51.net/article/205225.htm

c#中的Postgresql Npgsql.PostgresException
public void connectDB() { try { server = "localhost"; database = "DoveVer3"; uid = "admin"; password = "admin"; string connectionString; connectionString = "Host=" + server + ";Username =" + uid + ";" + "PASSWORD=" + password + ";DATABASE=" + database; connection.ConnectionString = connectionString; connection.open(); } catch (Exception e) { MessageBox.Show(e.Message); } }
我在下面的代码中获得了Exeption:
public void AddDovetoDB(Dove dove) { //add new dove record to tableDB connectDB(); cmd = new NpgsqlCommand(); cmd.Connection = connection; cmd.CommandText = "SELECT * FROM " + DoveTableDB + " WHERE `" + DoveIdColumnDoveTable + "` = '" + dove.GetDoveId() + "'"; NpgsqlDataReader rdr = cmd.ExecuteReader(); //// <<<<< HERE if (rdr.Read() != true) { rdr.Close(); cmd.Parameters.Clear(); cmd.CommandText = "INSERT INTO " + DoveTableDB + "(" + DoveIdColumnDoveTable + "," + DoveIdFatherColumnDoveTable + "," + DoveIdMotherColumnDoveTable + "," + DoveEyesColorColumnDoveTable + "," + DoveFeatherColorDoveTable + "," + DoveImageNameColumnDoveTable + "," + DoveSexColumnDoveTable +") VALUES ('" + dove.GetDoveId() + "','" + dove.GetDoveFatherId() + "','" + dove.GetDoveMotherId() + "','" + dove.GetEyesColor() + "','" + dove.GetFeathersColor()+ "','" + dove.GetimageName() + "','" + dove.GetSex()+ "')"; cmd.ExecuteNonQuery(); } connection.Close(); }
我的数据库名为DoveVer3,我的架构DoveSchema在这里是我的表代码:
Name: DoveTable; Type: TABLE; Schema: DoveSchema; Owner: admin -- CREATE TABLE "DoveTable" ( "doveId" character varying(20)[] NOT NULL,"doveFather" character varying(20)[],"doveMother" character varying,"doveEyesColor" character varying(20)[],"doveFeathersColor" character varying(20)[],"doveSex" smallint DEFAULT 3 NOT NULL,"imageName" character varying(30) ); ALTER TABLE "DoveTable" OWNER TO admin;
例外基础信息:
relation “dovetable” don’t exist; Statemants: {SELECT * FROM DoveTable
WHEREdoveId
= ‘Test’}
解决方法
SELECT * FROM "DoveTable"
请注意,它用双引号括起来,’D’和’T’都是大写的.使用带引号的标识符时,必须始终按照定义它们的方式将它们写出来.
centos 7下源码编译安装php支持PostgreSQL postgresql手册 postgresql官网下载 postgresql视频教
1. 下载源码
$ mkdir /usr/downloads $ wget -c http://cn2.php.net/distributions/php-5.6.20.tar.gz $ tar -xvf php-5.6.20.tar.gz $ mv php-5.6.20 /usr/local/src $ cd !$ & cd php-5.6.20
2. 阅读安装指导
$ ls -also $ less README $ less INSTALL
3. 安装依赖包
$ yum install apr apr-util apr-devel apr-util-devel prce lynx
4. 安装httpd
$ wget -c http://apache.fayea.com//httpd/httpd-2.4.20.tar.gz $ tar -xvf httpd-2.4.20.tar.gz $ cd httpd-2.4.20 $ ./configure \ --prefix=/usr/local/programs/apache2 \ --enable-rewrite \ --enable-so \ --enable-headers \ --enable-expires \ --with-mpm=worker \ --enable-modules=most \ --enable-deflate \ --enable-module=shared $ make $ make install $ cd /usr/local/programs/apache2 $ cp bin/apachectl /etc/init.d/httpd ## 复制启动脚本 $ /etc/init.d/httpd start ## 启动apache服务器,访问http://localhost/ $ egrep -v ''^[ ]*#|^$'' /usr/local/apache2/conf/httpd.conf | nl ## 查看apache服务器的配置 ## 将apache加入系统服务 vi /etc/rc.d/rc.local ``` /usr/local/programs/apache2/bin/apachectl start ``` $ cat /etc/rc.local
4. 安装postgresql
立即学习“PHP免费学习笔记(深入)”;
$ yum install readline-devel ## 安装readline依赖 $ cd /usr/downloads $ wget -c https://ftp.postgresql.org/pub/source/v9.5.0/postgresql-9.5.0.tar.bz2 $ tar -xvf postgresql-9.5.0.tar.bz2 $ cd postgresql-9.5.0 $ ./configure --prefix=/usr/local/programs/postgresql $ make $ su $ make install $ /sbin/ldconfig /usr/local/programs/postgresql/lib ## 刷新下共享动态库 $ cd /usr/local/programs/postgresql $ bin/psql --version ## 检查运行情况 ## 开始对postgresql的配置 $ vi /etc/profile.d/postgresql.sh ## 增加环境变量,不推荐直接在/etc/profile中添加,系统更新升级时会需要merge ``` PATH=/usr/local/programs/postgresql:$PATH export PATH ``` $ source /etc/profile ## 更新环境变量 ## 增加用户和其他文件夹 $ adduser postgres $ passwd postgres $ mkdir /usr/local/programs/postgresql/logs $ mkdir /usr/local/programs/postgresql/data $ chown postgres /usr/local/programs/postgresql/data $ su - postgres ## 初始化数据库 $ ./bin/initdb -D ./data $ ./bin/createdb test $ ./bin/psql test ## 已有数据库,可导入data文件夹后尝试root访问,假如带密码,可能需要进一步研究下 $ ./bin/postgres -D ./data >./logs/start-log-1.log 2>&1 & $ ./bin/psql --list ##列出数据库 ## ok,安装完成 ## 自定义设置,权限控制等,可以跳过,等熟悉使用后再做 ## 编辑数据库配置及权限文件: $ vi /usr/local/programs/postgresql/data/postgresql.conf ## 数据库配置文件 $ chown postgres postgresql.conf $ chmod 644 postgresql.conf $ vi /usr/local/programs/postgresql/data/pg_hba.conf ## 权限文件 $ vi /usr/local/programs/postgresql/data/pg_ident.conf ## 设置开机自启动: $ vi /etc/rc.d/rc.local ## 添加如下内容 ``` /usr/local/programs/postgresql/bin/postgresql start ```
5. 安装php
## 源码已经在第一步中下载,现在开始安装: $ yum install libxml2 libxml2-devel libpng libpng-devel libjpeg libjpeg-devel freetype freetype-devel $ ./configure \ --prefix=/usr/local/programs/php \ --with-apxs2=/usr/local/programs/apache2/bin/apxs \ --with-zlib \ --with-gd \ --with-jpeg-dir \ --with-png-dir \ --with-freetype-dir \ --with-zlib-dir \ --enable-mbstring \ --with-pgsql=/usr/local/programs/postgresql \ --with-pdo-pgsql=/usr/local/programs/postgresql $ make $ make test > Bug #42718 (unsafe_raw filter not applied when configured as default filter) [ext/filter/tests/bug42718.phpt] XFAIL REASON: FILTER_UNSAFE_RAW not applied when configured as default filter, even with flags > Bug #67296 (filter_input doesn''t validate variables) [ext/filter/tests/bug49184.phpt] XFAIL REASON: See Bug #49184 > Bug #53640 (XBM images require width to be multiple of 8) [ext/gd/tests/bug53640.phpt] XFAIL REASON: Padding is not implemented yet > zend multibyte (7) [ext/mbstring/tests/zend_multibyte-07.phpt] XFAIL REASON: https://bugs.php.net/bug.php?id=66582 > zend multibyte (9) [ext/mbstring/tests/zend_multibyte-09.phpt] XFAIL REASON: https://bugs.php.net/bug.php?id=66582 >Bug #70470 (Built-in server truncates headers spanning over TCP packets) [sapi/cli/tests/bug70470.phpt] XFAIL REASON: bug is not fixed yet ## 查阅官方的bug,发现: > id=66582: status : Closed. Fixed in master (PHP7) > id=42718: status : Assigned > id=42718: reference to id=49184, unsolved for many years ## 那就不关心了,直接装吧 $ make install > You may want to add: /usr/local/programs/php/lib/php to your php.ini include_path ## 那就按它说的设置吧 $ cp php.ini-development /usr/local/programs/php/lib/php.ini ``` include_path = ".;/usr/local/programs/php/lib/php" ## 然后,编辑httpd的设置,确保其能正确解析php文件 ``` ... LoadModule php5_module modules/libphp5.so ... AddType application/x-httpd-php .php AddType application/x-httpd-php-source .php5 ... <ifmodule dir_module> DirectoryIndex index.html index.php </ifmodule> ``` ## 重启httpd,测试 $ cd /usr/local/programs/apache2 $ bin/httpd -h $ bin/httpd -k stop $ bin/httpd -f conf/httpd.conf ## 默认设置的www页面在./htdocs/下,那就先去里面建一个测试页面吧 $ vi htdocs/index.php ``` <?php phpinfo(); ?> ``` $ curl http://localhost/index.php |grep postgresql #ok
后续应该做的事
* 1. 启动时,不需要要手动指定配置文件
* 2. php初始化www目录设置
* 3. php 用户、权限管理等
以上就介绍了centos 7下源码编译安装php支持PostgreSQL,包括了postgresql,centos 7方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
Postgresql - Expression Indexes
Having covered virtual columns recently, I wanted to cover one additional type of stored value, expression indexes. Unlike virtual columns, which are computed on each access, expression indexes are stored in index files, allowing rapid access. Let''s look at some examples, building on the customer table and fullnamefunction created in my previous blog entry:
CREATE INDEX i_customer_lastname ON customer (lastname);
CREATE INDEX i_customer_concat ON customer ((firstname || '' '' || lastname));
CREATE INDEX i_customer_fullname ON customer (fullname(customer));
The first create index command simply creates a copy of the column lastname in a btree-ordered index file. The second example concatenates firstname andlastname fields and stores the result in a btree-ordered index file; it requires double-parentheses around the expression. The last example stores the output of the function fullname in an index file.
The ability to store the output of expressions and functions allows rapid access for queries that are more complex than simple column comparisons. For example,
SELECT * FROM customer WHERE firstname || '' '' || lastname = ''Mark Pennypincher'';
id | firstname | lastname
----+-----------+--------------
1 | Mark | Pennypincher
SELECT * FROM customer WHERE fullname(customer) = ''Mark Pennypincher'';
id | firstname | lastname
----+-----------+--------------
1 | Mark | Pennypincher
SELECT * FROM customer WHERE customer.fullname = ''Mark Pennypincher'';
id | firstname | lastname
----+-----------+--------------
1 | Mark | Pennypincher
Explain
allows us to see the index being used:
EXPLAIN SELECT * FROM customer WHERE firstname || '' '' || lastname = ''Mark Pennypincher'';
QUERY PLAN
-------------------------------------------------------------------------------------
Index Scan using i_customer_fullname on customer (cost=0.29..8.31 rows=1 width=12)
Index Cond: (((firstname || '' ''::text) || lastname) = ''Mark Pennypincher''::text)
EXPLAIN SELECT * FROM customer WHERE fullname(customer) = ''Mark Pennypincher'';
QUERY PLAN
-------------------------------------------------------------------------------------
Index Scan using i_customer_fullname on customer (cost=0.29..8.31 rows=1 width=12)
Index Cond: (((firstname || '' ''::text) || lastname) = ''Mark Pennypincher''::text)
EXPLAIN SELECT * FROM customer WHERE customer.fullname = ''Mark Pennypincher'';
QUERY PLAN
-------------------------------------------------------------------------------------
Index Scan using i_customer_fullname on customer (cost=0.29..8.31 rows=1 width=12)
Index Cond: (((firstname || '' ''::text) || lastname) = ''Mark Pennypincher''::text)
Notice that all three use the i_customer_fullname index. The sql fullname function was inlined when the index was created, so it was expanded to (((firstname || '' ''::text) || lastname); the i_customer_concat index is simply unnecessary. Storing Soundex values in expression indexes is also useful.
Basically, you have three options for creating auto-generated columns:
- virtual columns, via functions, computed on access
- computed table columns, populated by triggers
- computed index columns, populated by expression indexes
Of course, only the last one, expression indexes, allows rapid access to computed values. The example below uses sql to find the input value that yields the supplied factorial output value, e.g. what value generates a factorial of 120:
-- create a table of 1000 integers
CREATE TABLE factorial_lookup AS SELECT i FROM generate_series(1, 1000) x(i);
-- compute a factorial for every row and compare
EXPLAIN SELECT i FROM factorial_lookup WHERE factorial(i) = 120;
QUERY PLAN
------------------------------------------------------------------
Seq Scan on factorial_lookup (cost=0.00..52.00 rows=12 width=4)
Filter: (factorial((i)::bigint) = 120::numeric)
-- create an index of factorial output values
CREATE INDEX i_factorial_lookup ON factorial_lookup (factorial(i));
-- generate optimizer statistics
ANALYZE factorial_lookup;
-- use the index for rapid factorial output comparison
EXPLAIN SELECT i FROM factorial_lookup WHERE factorial(i) = 120;
QUERY PLAN
-------------------------------------------------------------------------------------------
Index Scan using i_factorial_lookup on factorial_lookup (cost=0.53..8.55 rows=1 width=4)
Index Cond: (factorial((i)::bigint) = 120::numeric)
Interestingly, Postgres computes optimizer statistics on expression indexes, even though the expressions do not exist in any table:
SELECT attname FROM pg_stats WHERE tablename = ''i_factorial_lookup'';
attname
-----------
factorial
Expressions indexes are just another tool available to Postgres database users — they allow rapid access to rows based on table column expressions and functions.
PostgreSQL 11 新特性之覆盖索引(Covering Index)
文章目录
通常来说,索引可以用于提高查询的速度。通过索引,可以快速访问表中的指定数据,避免了表上的扫描。
有时候,索引不仅仅能够用于定位表中的数据。某些查询可能只需要访问索引的数据,就能够获取所需要的结果,而不需要再次访问表中的数据。这种访问数据的方法叫做 Index-Only 扫描。
要想通过索引直接返回查询的数据,创建的索引需要包含 SELECT 列表中的所有字段:
CREATE TABLE t1 (a int, b int, c int);
INSERT INTO t1
SELECT val, val + 1, val * 2
FROM generate_series(1, 100000) as val;
CREATE UNIQUE INDEX idx_t1_ab ON t1(a, b);
ANALYZE;
以下查询使用字段 a 作为条件,并返回 a 和 b:
EXPLAIN SELECT a, b FROM t1 WHERE a BETWEEN 100 AND 200;
QUERY PLAN |
--------------------------------------------------------------------------|
Index Only Scan using idx_t1_ab on t1 (cost=0.29..166.00 rows=98 width=8)|
Index Cond: ((a >= 100) AND (a <= 200)) |
通过查询计划可以看出,以上查询使用了 Index-Only Scan,直接通过索引扫描就可以返回查询的结果。
许多数据库产品对于这种包含了查询结果的索引称为覆盖索引(covering index),不过更准确的说法应该是 Index-Only 扫描。它只是执行计划访问数据的一种方式,而不是一种新的索引。
我们修改一下查询,仍然以字段 a 作为查询条件,但是要求返回 a 和 c:
EXPLAIN SELECT a, c FROM t1 WHERE a BETWEEN 100 AND 200;
QUERY PLAN |
---------------------------------------------------------------------|
Index Scan using idx_t1_ab on t1 (cost=0.29..166.00 rows=98 width=8)|
Index Cond: ((a >= 100) AND (a <= 200)) |
由于字段 c 不在索引 idx_t1_ab 中,查询虽然使用了索引扫描,但是仍然需要通过索引二次查询表中的数据。如果想要使用 Index-Only 扫描,需要再基于字段 a,c 创建一个新的索引。
如果查询需要返回 a,b,c,还需要第 3 个索引。如果使用 a,c 上的索引替代 idx_t1_ab,又无法保证 a,b 上的唯一性。
为此,Postresql 11 提供了一个新的索引子句,即 INCLUDE 子句:
DROP INDEX idx_t1_ab;
CREATE UNIQUE INDEX idx_t1_ab ON t1 USING btree (a, b) INCLUDE (c);
ANALYZE;
Db2 和 sql Server 也有类似 INCLUDE 子句。
以上唯一索引仍然基于字段 a,b 创建,同时使用 INCLUDE 子句在索引的叶子节点存储字段 c 的值。因此,以下查询也能够使用 Index-Only 扫描:
EXPLAIN SELECT a, c FROM t1 WHERE a BETWEEN 100 AND 200;
QUERY PLAN |
---------------------------------------------------------------------------|
Index Only Scan using idx_t1_ab on t1 (cost=0.42..176.77 rows=105 width=8)|
Index Cond: ((a >= 100) AND (a <= 200)) |
EXPLAIN SELECT a, b, c FROM t1 WHERE a=100 and b BETWEEN 100 AND 200;
QUERY PLAN |
------------------------------------------------------------------------|
Index Only Scan using idx_t1_ab on t1 (cost=0.42..8.44 rows=1 width=12)|
Index Cond: ((a = 100) AND (b >= 100) AND (b <= 200)) |
接下来看一看官方文档中的介绍:
CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [ IF NOT EXISTS ] name ] ON [ ONLY ] table_name [ USING method ]
( { column_name | ( expression ) } [ COLLATE collation ] [ opclass ] [ ASC | DESC ] [ NULLS { FirsT | LAST } ] [, ...] )
[ INCLUDE ( column_name [, ...] ) ]
[ WITH ( storage_parameter = value [, ... ] ) ]
[ TABLESPACE tablespace_name ]
[ WHERE predicate ]
INCLUDE 子句可以为索引增加一些非键值的字段。这些非键字段不能用于索引的扫描条件,并且也不会参与索引的唯一性约束和排除约束。 不过,Index-Only 扫描方式可以返回这些非键字段的值,而不需要访问索引所在的表,因为可以直接从索引节点中直接返回它们的值。因此,在索引中包含非索引键的字段扩展了 Index-Only 扫描的使用场景。
使用上面的示例表:
EXPLAIN SELECT a, b FROM t1 WHERE a=100 and b =100 and c=100;
QUERY PLAN |
------------------------------------------------------------------------|
Index Only Scan using idx_t1_ab on t1 (cost=0.42..8.44 rows=1 width=12)|
Index Cond: ((a = 100) AND (b = 100)) |
Filter: (c = 100) |
查询计划中的索引扫描条件为 ‘((a = 100) AND (b = 100))’,而 ‘(c = 100)’ 只是作为过滤条件。
另外,索引 idx_t1_ab 的唯一性只能确保字段 a,b 的组合唯一,不包括字段 c 的值。
为索引添加非键字段时需要谨慎考虑,特别是宽列。如果一个索引记录超过了索引类型允许的最大值,数据操作将会失败。此外,非键字段重复存储了表中的数据,并且增加了索引的大小,可能会导致查询变慢。
INCLUDE 子句中的列不需要相应的操作符类;该子句可以包含没有为特定访问方式定义操作符的数据类型。因为这些字段仅仅用于返回数据,而不参与索引的扫描。
表达式(函数)不能作为 INCLUDE 字段,因为 Index-Only 扫描不支持表达式。
CREATE UNIQUE INDEX idx_t1_exp ON t1(a, b) INCLUDE ((c+1));
sql Error [0A000]: ERROR: expressions are not supported in included columns
目前只有 B-tree 索引支持 INCLUDE 子句。在 B-tree 索引中 ,INCLUDE 子句中的字段值只存储在叶子节点中,而不会包含在上层的导航节点中。
覆盖索引还是优化连接查询的一个非常好的方法,参考:Covering Indexes for Query Optimization
参考文章:Postgres 11 highlight - Covering Indexes
人生本来短暂,你又何必匆匆!点个赞再走吧!
我们今天的关于PostgreSQL之INDEX 索引详解的分享就到这里,谢谢您的阅读,如果想了解更多关于c#中的Postgresql Npgsql.PostgresException、centos 7下源码编译安装php支持PostgreSQL postgresql手册 postgresql官网下载 postgresql视频教、Postgresql - Expression Indexes、PostgreSQL 11 新特性之覆盖索引(Covering Index)的相关信息,可以在本站进行搜索。
本文标签: