postgres 错误:mergejoin 输入数据乱序

问题描述 投票:0回答:1

我的 postgres 数据库中有两个表,关系和版本信息:

postgres=# \d+ relations
                                                                 Table "public.relations"
                Column                |            Type             | Collation | Nullable | Default | Storage  | Compression | Stats target | Description 
--------------------------------------+-----------------------------+-----------+----------+---------+----------+-------------+--------------+-------------
 system_name                          | character varying           |           |          |         | extended |             |              | 
 from_package_name                    | character varying           |           |          |         | extended |             |              | 
 from_version                         | semver                      |           |          |         | plain    |             |              | 
 to_package_name                      | character varying           |           |          |         | extended |             |              | 
 actual_requirement                   | character varying           |           |          |         | extended |             |              | 
 to_version                           | semver                      |           |          |         | plain    |             |              | 
 to_package_highest_available_release | character varying           |           |          |         | extended |             |              | 
 interval_start                       | timestamp without time zone |           |          |         | plain    |             |              | 
 interval_end                         | timestamp without time zone |           |          |         | plain    |             |              | 
 is_out_of_date                       | boolean                     |           |          |         | plain    |             |              | 
 is_regular                           | boolean                     |           |          |         | plain    |             |              | 
 warnings                             | character varying           |           |          |         | extended |             |              | 
Access method: heap
postgres=# \d+ versioninfo
                                                    Table "public.versioninfo"
    Column    |            Type             | Collation | Nullable | Default | Storage  | Compression | Stats target | Description 
--------------+-----------------------------+-----------+----------+---------+----------+-------------+--------------+-------------
 system_name  | character varying           |           |          |         | extended |             |              | 
 package_name | character varying           |           |          |         | extended |             |              | 
 version_name | semver                      |           |          |         | plain    |             |              | 
 release_date | timestamp without time zone |           |          |         | plain    |             |              | 
Access method: heap

我根据某些标准加入他们:

CREATE TABLE exclude_records AS
SELECT R2.system_name, R2.from_package_name, R2.from_version, R2.to_package_name, COUNT(*) AS count_no
FROM relations R2
INNER JOIN versioninfo V3
ON R2.from_package_name = V3.package_name AND R2.from_version = V3.version_name AND R2.system_name = V3.system_name
INNER JOIN versioninfo V4
ON R2.to_package_name = V4.package_name AND R2.to_version = V4.version_name AND R2.system_name = V4.system_name
GROUP BY R2.system_name, R2.from_package_name, R2.from_version, R2.to_package_name
HAVING COUNT(*) > 1;

但是这个查询返回错误:

ERROR:  mergejoin input data is out of order 

SQL state: XX000

无法弄清楚问题出在哪里。我的理解是,为了使用内连接连接表,postgres 使用

mergejoin
(因为 ON 条件包含相等运算符,并且这两个表非常大)。这可能是这个错误的原因?

sql postgresql semantic-versioning
1个回答
0
投票

根据讨论,通过转换为

VARCHAR
或使用
REINDEX
来解决问题。感谢您的评论!

© www.soinside.com 2019 - 2024. All rights reserved.