Can you create an index on a foreign table?(外部表可以创建索引吗?)

简介: 来自google搜索的一段回答No, you will get an error:ERROR: cannot create index on foreign table "tablename"********** Error **********ERROR: cannot create...

来自google搜索的一段回答

No, you will get an error:

ERROR:  cannot create index on foreign table "tablename"
********** Error **********

ERROR: cannot create index on foreign table "tablename"
SQL state: 42809

And it makes sense as the query will "travel" througth the net and retrieve the data from the original database each time you query the table (will not store data to index).

What you can do is to use explain verbose to get the query that is being execute on the other side , and index the remote table accordingly .

explain verbose select * from schema.foreign_table

"Foreign Scan on schema.foreign_table  (cost=25.00..1025.00 rows=1000 width=84)"
"  Output: field1, field2, field3
"  Remote server startup cost: 25"
"  Remote query: SELECT field1, field2, field3 FROM schema.original_table

Hope that helps. Good luck!

相关文章
|
7月前
|
关系型数据库 MySQL 数据库
对于mysql数据库delect from,truncate table,drop table, update操作的时候如何选择
对于mysql数据库delect from,truncate table,drop table, update操作的时候如何选择
67 2
|
4月前
|
存储 SQL 关系型数据库
CREATE TABLE语句
在MySQL中,使用CREATE TABLE语句来创建表。你需要指定表名和列的定义,包括列名、数据类型以及约束等,结合实际存储和上一课学习的数据类型选取合适的。创建一个book_types表
155 0
|
11月前
|
SQL 存储 关系型数据库
PostgreSQL 动态表复制(CREATE TABLE AS & CREATE TABLE LIKE)
PostgreSQL 动态表复制(CREATE TABLE AS & CREATE TABLE LIKE)
|
JavaScript 前端开发 数据可视化
vxe-table
vxe-table
585 0
vxe-table
|
SQL HIVE
HIVE: create table 与 create external table 区别
HIVE: create table 与 create external table 区别
|
SQL 数据库
CREATE TABLE
CREATE TABLE
111 0
|
SQL 数据库
CREATE TABLE 语句
CREATE TABLE 语句
106 1
|
Java 索引
Table(表)
Table(表)
72 0
|
SQL Oracle 关系型数据库
SQL FOREIGN KEY Constraint on CREATE TABLE
SQL FOREIGN KEY Constraint on CREATE TABLE
63 1
瞬表——Ephemeron Table
瞬表——Ephemeron Table
112 0