小编Lau*_*lbe的帖子

PostgreSQL的CLUSTER与SQL Server中的聚簇索引有何不同?

许多像这样的stackoverflow链接的帖子声称PostgreSQL中没有聚集索引的概念.但是,PostgreSQL文档包含类似的内容.一些人声称它类似于SQL Server中的聚簇索引.

你知道这两者之间的确切区别是什么,如果有的话?

postgresql clustered-index

6
推荐指数
1
解决办法
1059
查看次数

剩余的连接槽保留用于非复制超级用户连接

我目前有一个 django 应用程序,并且有一个 PostgreSQL 数据库。我研究了这个错误,并在 Stackoverflow 上找到了其他答案,但似乎没有人回答我的确切问题。向服务器发出请求时出现此错误。请注意,我目前正在本地运行我的应用程序。我的很多视图都包含对数据库的请求:

django.db.utils.OperationalError: FATAL:  remaining connection slots are reserved for non-replication superuser connections
Run Code Online (Sandbox Code Playgroud)

以下是我的 settings.py 文件中的数据库配置:

任何帮助将不胜感激!

DATABASES = {
    'default': {
        'ENGINE': 'django_postgrespool',
        'NAME': 'database',
        'USER': 'user',
        'PASSWORD': 'password',
        'HOST': 'localhost',
        'PORT': '5432',
        'CONN_MAX_AGE': 0,
    }
}
Run Code Online (Sandbox Code Playgroud)

python django postgresql

6
推荐指数
1
解决办法
1万
查看次数

VBA Excel中的魔术括号

我写了一些函数来添加一些折线到Excel工作表.然后我发现了奇怪的括号行为.我声明并定义点数组如下:

Dim points As Variant
Dim sh As Shape

points = Array(Array(10.5, 10.5), Array(20.4, 20.4), Array(5.1, 30.3), Array(10.5, 10.5))

' These both do not work and I get error about wrong type (error 1004) in 2007
' and application defined error 1004 on 2010:

ActiveWorkbook.ActiveSheet.Shapes.AddPolyline points
Set sh = ActiveWorkbook.ActiveSheet.Shapes.AddPolyline(points)

' These work fine:

ActiveWorkbook.ActiveSheet.Shapes.AddPolyline (points)
Set sh = ActiveWorkbook.ActiveSheet.Shapes.AddPolyline((points))
Run Code Online (Sandbox Code Playgroud)

VBA括号的奇怪魔力是什么?

测试了2007年和2010年版本.

excel vba excel-vba

6
推荐指数
1
解决办法
105
查看次数

PostgreSQL C 语言函数中的 Datum 到底是什么?

到目前为止,我知道这Datum是 PostgreSQL 中 C 语言函数中使用的数据类型之一,它可以表示有效 SQL 类型中的任何值。我没有得到的是,如果它可以保存任何类型的值,那么调用函数如何知道被调用函数返回的值的数据类型?Datum 在内部是一个包含此类附加信息的结构吗?请解释。

c postgresql

6
推荐指数
2
解决办法
1832
查看次数

Postgres 从 10.4 升级到 11.5 数据库“postgres”的编码不匹配:旧的“SQL_ASCII”,新的“UTF8”

目前正在检查将 Postgres 从 10.4 升级到 11.5 的过程。

当我pg_upgrade使用“检查”选项运行时,我收到以下消息。如果您对此以及如何解决该问题有任何意见,我将不胜感激。

bash-4.2$ /usr/pgsql-11/bin/pg_upgrade \
> -b /usr/pgsql-10/bin \
> -B /usr/pgsql-11/bin \
> -d /var/lib/pgsql/10/data \
> -D /var/lib/pgsql/11/data \
> -c pgsql-10/ pgsql-11/

Performing Consistency Checks on Old Live Server
------------------------------------------------
Checking cluster versions                                   
ok
Checking database user is the install user                  
ok
Checking database connection settings                       
ok
Checking for prepared transactions                          
ok
Checking for reg* data types in user tables                 
ok
Checking for contrib/isn with bigint-passing mismatch       
ok

encodings …
Run Code Online (Sandbox Code Playgroud)

database postgresql encoding upgrade

6
推荐指数
1
解决办法
2503
查看次数

Postgresql 使用自定义停用词列表创建搜索配置

对于特定的全文搜索,我需要修改标准停用词文件并排除一些单词。到目前为止我做了什么:

复制german.stopgerman_modified.stop,然后从 中删除文字german_modified.stop。然后:

CREATE TEXT SEARCH DICTIONARY public.german_nostop (
   TEMPLATE = pg_catalog.simple,
   STOPWORDS = german_modified
);

CREATE TEXT SEARCH CONFIGURATION public.german_nostop (
   COPY = pg_catalog.german
);

ALTER TEXT SEARCH CONFIGURATION public.german_nostop
   ALTER MAPPING
      FOR asciiword, asciihword, hword_asciipart, hword, hword_part, word
      WITH german_nostop;

CREATE INDEX body_idx ON comments
   USING gin (to_tsvector('german_nostop', body));
Run Code Online (Sandbox Code Playgroud)

但当我这样做时

SELECT body, autor
FROM comments
WHERE to_tsvector('german_nostop', body) @@ to_tsquery('wie');
Run Code Online (Sandbox Code Playgroud)

我得到:

NOTICE:  text-search query contains only stop words or doesn't contain lexemes, …
Run Code Online (Sandbox Code Playgroud)

postgresql full-text-indexing

5
推荐指数
1
解决办法
1592
查看次数

如何在PostgreSQL函数中使用COMMIT和ROLLBACK

我使用三个插入语句,如果第三个语句中有错误,我想回滚第一个和第二个.如果没有办法做到这一点,请告诉我一个不同的方法来处理PostgresqQL中的这个.

如果我使用COMMITROLLBACK,我收到错误.

CREATE OR REPLACE FUNCTION TEST1 ()
   RETURNS VOID
   LANGUAGE 'plpgsql'
   AS $$
BEGIN 

    INSERT INTO table1 VALUES (1);

    INSERT INTO table1 VALUES (2);

    INSERT INTO table1 VALUES ('A');
    COMMIT;
EXCEPTION
   WHEN OTHERS THEN
   ROLLBACK;
END;$$;
Run Code Online (Sandbox Code Playgroud)

上面的代码不起作用; COMMIT并且ROLLBACKPostgreSQL函数不支持.

postgresql postgresql-10

5
推荐指数
1
解决办法
1万
查看次数

在 Postgres SQL 查询的 WHERE 子句中指定日期的时区

在 Postgres 中,我总是使用带时区的时间戳来存储我的日期。

为便于讨论,假设我必须在 2018 年 1 月 16 日东部时区 (EST -04) 的时间(上午 8 点、下午 1 点和晚上 10 点)存储事件。数据库中的时间戳将是:

  • 上午 8 点:“2018-01-16 12:00:00.000+00”
  • 下午 1 点:“2018-01-16 17:00:00.000+00”
  • 晚上10点:“2018-01-17 02:00:00.000+00”

我将如何编写 Postgres SQL 查询来获取 2018-01-16 EST 上发生的所有事件?

postgresql datetime

5
推荐指数
1
解决办法
2255
查看次数

如何为 PostgreSQL 中的表创建同义词

我正在将此 Oracle 命令迁移到 PostgreSQL:

CREATE SYNONYM &user..emp FOR &schema..emp;
Run Code Online (Sandbox Code Playgroud)

请向我建议如何迁移上述命令。

postgresql database-migration synonym

5
推荐指数
1
解决办法
2万
查看次数

PostgreSQL 11 在索引应该足够的分区表上进行并行 seq 扫描

问题是我一直在一个相当简单的查询上获得 seq 扫描,这是一个非常简单的设置。我究竟做错了什么?

  • Windows Server 2016 上的 Postgres 11
  • 配置更改完成: constraint_exclusion = partition
  • 单个表分区为 200 个子表,每个分区有数十万条记录。
  • 相关字段的索引(假设一个字段也已分区)

这是创建语句:

CREATE TABLE A (
    K int NOT NULL,
    X bigint NOT NULL,
    Date timestamp NOT NULL,
    fy smallint NOT NULL,
    fz decimal(18, 8) NOT NULL,
    fw decimal(18, 8) NOT NULL,
    fv decimal(18, 8) NULL,
    PRIMARY KEY (K, X)
) PARTITION BY LIST (K);

CREATE TABLE A_1 PARTITION OF A FOR VALUES IN (1);
CREATE TABLE A_2 PARTITION OF A FOR VALUES IN …
Run Code Online (Sandbox Code Playgroud)

postgresql query-optimization database-partitioning database-indexes postgresql-11

5
推荐指数
1
解决办法
1654
查看次数