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!

相关文章
|
Java 数据库连接 数据库
强大:MyBatis ,三种流式查询方法
流式查询指的是查询成功后不是返回一个集合而是返回一个迭代器,应用每次从迭代器取一条查询结果。流式查询的好处是能够降低内存使用。
强大:MyBatis ,三种流式查询方法
|
5月前
|
关系型数据库 MySQL Linux
查看Linux、Apache、MySQL、PHP版本的技巧
以上就是查看Linux、Apache、MySQL、PHP版本信息的方法。希望这些信息能帮助你更好地理解和使用你的LAMP技术栈。
283 17
|
Ubuntu Unix Linux
在Ubuntu安装RPM文件
Ubuntu软件源包含数千个deb软件包,可以从Ubuntu软件中心或使用apt命令行安装。 Deb是所有基于Debian的Linux发行版,例如包括Ubuntu,Linux mint等发行版使用的安装包格式。 如果某些软件在Ubuntu软件源中不可用,可以通过启用适当的软件源来安装,然后使用APT命令安装。 在大多数情况下,当软件开发者不提供软件源时,他们都有一个下载页面,您可以在该页面下载并安装deb软件包,或者下载源码然后编译。 虽然不常见,但某些软件开发者可能会仅发布RPM包格式的文件。RPM是Red Hat及其衍生的Linux发行版,例如如CentOS,Fedora使用软件包
274 5
|
JavaScript 前端开发 IDE
TypeScript取代JavaScript的优势
TypeScript取代JavaScript的优势
|
9月前
|
Go 索引
go语言for遍历数组或切片
go语言for遍历数组或切片
294 62
|
Unix Go
Golang语言标准库time之日期和时间相关函数
这篇文章是关于Go语言日期和时间处理的文章,介绍了如何使用Go标准库中的time包来处理日期和时间。
450 3
|
SQL 负载均衡 监控
【分布式任务调度平台 XXL-JOB 急速入门】从零开始将 XXL-JOB 接入到自己的项目(上)
【分布式任务调度平台 XXL-JOB 急速入门】从零开始将 XXL-JOB 接入到自己的项目
2043 0
|
PyTorch 算法框架/工具
在conda中如何查看安装的pytorch版本 - 蓝易云
这个命令会列出所有与pytorch相关的包,包括它们的版本号。你可以在列表中找到pytorch的版本号。
1398 1
【硬核解说】一口气讲明白Angular的5种路由守卫RouteGuard是嘛玩意儿
【硬核解说】一口气讲明白Angular的5种路由守卫RouteGuard是嘛玩意儿
【硬核解说】一口气讲明白Angular的5种路由守卫RouteGuard是嘛玩意儿
|
存储 关系型数据库 数据库
数据库索引的原理,为什么要用 B+树,为什么不用二叉树?
数据库索引的原理,为什么要用 B+树,为什么不用二叉树?