array
列有上限吗?
插入数组字段时出现此错误 -
PG::Error: ERROR: index row size 3480 exceeds maximum 2712 for index "ix_data"
Run Code Online (Sandbox Code Playgroud)
这是我的表定义 -
create table test_array(id varchar(50), data text[]);
ALTER TABLE test_array ADD PRIMARY KEY (id);
CREATE INDEX ix_data ON test_array USING GIN (data);
Run Code Online (Sandbox Code Playgroud)
我需要数组字段的索引,因为我正在对它进行一些查找。
我一生都无法弄清楚如何在我的 json 列的整数属性上创建索引。
我以这种方式尝试过(以及其他数十种方式)
CREATE INDEX user_reputation_idx ON users(("user"->>'reputation')::int)
Run Code Online (Sandbox Code Playgroud)
它在查询中工作得很好(例如ORDER BY ("user"->>'reputation')::int
)
我错过了什么?
更新
我收到一个简单的语法错误,但是,我真的不知道为什么。
ERROR: syntax error at or near "::"
LINE 1: ... user_reputation_idx ON users (("user"->>'reputation')::int)
Run Code Online (Sandbox Code Playgroud)
表定义非常简单。它只是一列user
type json
。
所以,看起来像这样:
CREATE TABLE users
(
"user" json
)
Run Code Online (Sandbox Code Playgroud) 继我之前的相关问题之后,让我详细说明一下这个话题。
raster2pgsql
是一个光栅加载器可执行文件,它在 PostGIS 中加载 GDAL 支持的光栅格式。它有一个-C
定义如下的标志:
gislinux@gislinux-Precision-M4600:~$ raster2pgsql
输出:
-C Set the standard set of constraints on the raster
column after the rasters are loaded. Some constraints may fail
if one or more rasters violate the constraint.
Run Code Online (Sandbox Code Playgroud)
当我像这样导入我的光栅文件时:
gislinux@gislinux-Precision-M4600:~$ raster2pgsql -d -I -C -M -F -t 100x100 -s 4326
us_tmin_2012.01.asc chp05.us_tmin_new | psql -h localhost -p 5432 -U postgres -d pgrouting
Run Code Online (Sandbox Code Playgroud)
输出:
ANALYZE
NOTICE: Adding SRID constraint
CONTEXT: PL/pgSQL function addrasterconstraints line 53 at RETURN …
Run Code Online (Sandbox Code Playgroud)