从PostgreSQL中的表中获取最大,最小时间戳值

杜伊亨特

编辑:看了评论中的建议。

该表(gas_station_information_history)约为5GB。

启动服务器,运行工作查询,然后运行MAX,MIN查询的日志文件为:

2020-02-03 12:39:54.931 CET [18022] LOG:  database system was shut down at 2020-02-03 12:38:55 CET
2020-02-03 12:39:54.936 CET [18020] LOG:  database system is ready to accept connections
2020-02-03 12:40:26.615 CET [18020] LOG:  background worker "parallel worker" (PID 18040) was terminated by sig$
2020-02-03 12:40:26.615 CET [18020] DETAIL:  Failed process was running: SELECT MAX(date), MIN(date)
        FROM gas_station_information_history;
2020-02-03 12:40:26.615 CET [18020] LOG:  terminating any other active server processes
2020-02-03 12:40:26.615 CET [18038] WARNING:  terminating connection because of crash of another server process
2020-02-03 12:40:26.615 CET [18038] DETAIL:  The postmaster has commanded this server process to roll back the $
2020-02-03 12:40:26.615 CET [18038] HINT:  In a moment you should be able to reconnect to the database and repe$
2020-02-03 12:40:26.615 CET [18031] WARNING:  terminating connection because of crash of another server process
2020-02-03 12:40:26.615 CET [18031] DETAIL:  The postmaster has commanded this server process to roll back the $
2020-02-03 12:40:26.615 CET [18031] HINT:  In a moment you should be able to reconnect to the database and repe$
2020-02-03 12:40:26.616 CET [18027] WARNING:  terminating connection because of crash of another server process
2020-02-03 12:40:26.616 CET [18027] DETAIL:  The postmaster has commanded this server process to roll back the $
2020-02-03 12:40:26.616 CET [18027] HINT:  In a moment you should be able to reconnect to the database and repe$
2020-02-03 12:40:26.619 CET [18020] LOG:  all server processes terminated; reinitializing
2020-02-03 12:40:26.685 CET [18041] LOG:  database system was interrupted; last known up at 2020-02-03 12:39:54$
2020-02-03 12:40:26.748 CET [18041] LOG:  database system was not properly shut down; automatic recovery in pro$
2020-02-03 12:40:26.751 CET [18041] LOG:  redo starts at 3/F92C228
2020-02-03 12:40:26.751 CET [18041] LOG:  invalid record length at 3/F92C260: wanted 24, got 0
2020-02-03 12:40:26.751 CET [18041] LOG:  redo done at 3/F92C228
2020-02-03 12:40:26.784 CET [18020] LOG:  database system is ready to accept connections
2020-02-03 12:40:28.959 CET [18020] LOG:  background worker "parallel worker" (PID 18053) was terminated by sig$
2020-02-03 12:40:28.959 CET [18020] DETAIL:  Failed process was running: SELECT MAX(date), MIN(date)
        FROM gas_station_information_history;
2020-02-03 12:40:28.959 CET [18020] LOG:  terminating any other active server processes
2020-02-03 12:40:28.959 CET [18051] WARNING:  terminating connection because of crash of another server process
2020-02-03 12:40:28.959 CET [18051] DETAIL:  The postmaster has commanded this server process to roll back the $
2020-02-03 12:40:28.959 CET [18051] HINT:  In a moment you should be able to reconnect to the database and repe$
2020-02-03 12:40:28.959 CET [18049] WARNING:  terminating connection because of crash of another server process
2020-02-03 12:40:28.959 CET [18049] DETAIL:  The postmaster has commanded this server process to roll back the $
2020-02-03 12:40:28.959 CET [18049] HINT:  In a moment you should be able to reconnect to the database and repe$
2020-02-03 12:40:28.960 CET [18045] WARNING:  terminating connection because of crash of another server process
2020-02-03 12:40:28.960 CET [18045] DETAIL:  The postmaster has commanded this server process to roll back the $
2020-02-03 12:40:28.960 CET [18045] HINT:  In a moment you should be able to reconnect to the database and repe$
2020-02-03 12:40:28.964 CET [18020] LOG:  all server processes terminated; reinitializing
2020-02-03 12:40:29.038 CET [18054] LOG:  database system was interrupted; last known up at 2020-02-03 12:40:26$
2020-02-03 12:40:29.092 CET [18057] FATAL:  the database system is in recovery mode
2020-02-03 12:40:29.114 CET [18058] FATAL:  the database system is in recovery mode
2020-02-03 12:40:29.117 CET [18054] LOG:  database system was not properly shut down; automatic recovery in pro$
2020-02-03 12:40:29.121 CET [18054] LOG:  invalid record length at 3/F92C2D8: wanted 24, got 0
2020-02-03 12:40:29.121 CET [18054] LOG:  redo is not required
2020-02-03 12:40:29.154 CET [18020] LOG:  database system is ready to accept connections
2020-02-03 12:40:33.868 CET [18020] LOG:  received fast shutdown request
2020-02-03 12:40:33.869 CET [18020] LOG:  aborting any active transactions
2020-02-03 12:40:33.870 CET [18066] FATAL:  terminating connection due to administrator command
2020-02-03 12:40:33.871 CET [18020] LOG:  background worker "logical replication launcher" (PID 18064) exited w$
2020-02-03 12:40:33.873 CET [18059] LOG:  shutting down
2020-02-03 12:40:33.916 CET [18020] LOG:  database system is shut down

我在网上找不到任何东西background worker "parallel worker" was terminated by sig$

EXPLAIN在查询上运行会给出:

Finalize Aggregate  (cost=1034772.50..1034772.51 rows=1 width=16)
  ->  Gather  (cost=1034772.28..1034772.49 rows=2 width=16)
        Workers Planned: 2
        ->  Partial Aggregate  (cost=1033772.28..1033772.29 rows=1 width=16)
              ->  Parallel Seq Scan on gas_station_information_history  (cost=0.00..895677.85 rows=27618885 width=8)
JIT:
  Functions: 5
  Options: Inlining true, Optimization true, Expressions true, Deforming true

如何从Postgresql中的表中获取带有时区的第一个和最后一个记录的时间戳?时间戳列名称为“日期”。

我试过了

SELECT MAX(date), MIN(date)
FROM tablename;

断开了我的连接:“此套接字已被另一方终止”。我也尝试过

SELECT *
FROM table
ORDER BY date
LIMIT 10;

我查看了最大,最小和时间戳资源,例如,建议

SELECT MAX (date) AS "Max Date" 
FROM orders;

这给出了相同的断开错误。

如何进行这个简单的查询?谢谢!

杜伊亨特

我通过在日期列上添加索引解决了该问题。谢谢你的帮助!

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

在PostgreSQL中的时间戳上使用最小和最大函数

来自分类Dev

在PostgreSQL中的时间戳上使用最小和最大函数

来自分类Dev

如何从PostgreSQL中的时间戳获取小时,月份

来自分类Dev

Elastic(搜索):获取带有最大和最小时间戳值的文档

来自分类Dev

如何从给定表中获取最大时间戳行

来自分类Dev

获取最小值/最大值的时间戳

来自分类Dev

Mysql - sql 如何从包含第一个表 ID 的第二个表中获取最小时间和最大时间记录

来自分类Dev

从 unix 值中获取前一小时/前一天的时间戳

来自分类Dev

从 Scala/spark 中时间戳的数据帧列中获取最大值

来自分类Dev

如何获取Twig中的时间戳值?

来自分类Dev

如何获取Twig中的时间戳值?

来自分类Dev

如何从“ hh:mm”时间戳列表中获取最大值?

来自分类Dev

从每天的时间序列中获取最小值和最大值

来自分类Dev

Django从包含IntegerField的PostgreSQL特定ArrayField中获取最小值和最大值

来自分类Dev

获取大于或等于自身的 id 的最小时间戳

来自分类Dev

如何选择每个间隔的最大时间戳和最小时间戳

来自分类Dev

联接2个表并从第一个表中获取一些列,并从第二个表中获取最大时间戳值

来自分类Dev

从堆支持的最小优先级队列中获取最大值的时间复杂度

来自分类Dev

SQL查询:无法从多个表中获取一个时间戳之间的值计数

来自分类Dev

Oracle SQL中的时间戳+数字小时

来自分类Dev

如何在 PostgreSQL 中获取连接时间戳的 EPOCH

来自分类Dev

如何在此查询中获取每天的最大(小时)和最小(小时)?

来自分类Dev

如何在此查询中获取每天的最大(小时)和最小(小时)?

来自分类Dev

Python:从时间戳中添加或删除时区小时数并获取实际时间

来自分类Dev

同一表中的最小和最大日期时间

来自分类Dev

同一表中的最小和最大日期时间

来自分类Dev

获取Clojure中的最大值和最小值

来自分类Dev

在列表中获取最小值和最大值

来自分类Dev

获取Clojure中的最大值和最小值

Related 相关文章

  1. 1

    在PostgreSQL中的时间戳上使用最小和最大函数

  2. 2

    在PostgreSQL中的时间戳上使用最小和最大函数

  3. 3

    如何从PostgreSQL中的时间戳获取小时,月份

  4. 4

    Elastic(搜索):获取带有最大和最小时间戳值的文档

  5. 5

    如何从给定表中获取最大时间戳行

  6. 6

    获取最小值/最大值的时间戳

  7. 7

    Mysql - sql 如何从包含第一个表 ID 的第二个表中获取最小时间和最大时间记录

  8. 8

    从 unix 值中获取前一小时/前一天的时间戳

  9. 9

    从 Scala/spark 中时间戳的数据帧列中获取最大值

  10. 10

    如何获取Twig中的时间戳值?

  11. 11

    如何获取Twig中的时间戳值?

  12. 12

    如何从“ hh:mm”时间戳列表中获取最大值?

  13. 13

    从每天的时间序列中获取最小值和最大值

  14. 14

    Django从包含IntegerField的PostgreSQL特定ArrayField中获取最小值和最大值

  15. 15

    获取大于或等于自身的 id 的最小时间戳

  16. 16

    如何选择每个间隔的最大时间戳和最小时间戳

  17. 17

    联接2个表并从第一个表中获取一些列,并从第二个表中获取最大时间戳值

  18. 18

    从堆支持的最小优先级队列中获取最大值的时间复杂度

  19. 19

    SQL查询:无法从多个表中获取一个时间戳之间的值计数

  20. 20

    Oracle SQL中的时间戳+数字小时

  21. 21

    如何在 PostgreSQL 中获取连接时间戳的 EPOCH

  22. 22

    如何在此查询中获取每天的最大(小时)和最小(小时)?

  23. 23

    如何在此查询中获取每天的最大(小时)和最小(小时)?

  24. 24

    Python:从时间戳中添加或删除时区小时数并获取实际时间

  25. 25

    同一表中的最小和最大日期时间

  26. 26

    同一表中的最小和最大日期时间

  27. 27

    获取Clojure中的最大值和最小值

  28. 28

    在列表中获取最小值和最大值

  29. 29

    获取Clojure中的最大值和最小值

热门标签

归档