如何找到 postgres NOTIFY/LISTEN 消息 queue 的当前长度?
How to find the current length of a postgres NOTIFY/LISTEN message queue?
问题标题说明了一切。我们在数据库 table 上设置了 TRIGGERS,该数据库正被异地工作人员使用。然而,有时工作人员似乎在更新记录方面落后了。是否有 SQL 查询或调用以确定消息的现有长度 queue? (不弹出任何项目)。我在 postgres 文档和 other Whosebug questions 中看到很多关于此 queue 的提及,但找不到任何关于实际确定长度的信息。感谢您的帮助!
对于那些熟悉 redis 的人,我正在寻找与此 postgres 消息 queue.
等效的 LLEN
命令
我认为没有任何东西可以直接报告队列条目的数量。
最接近的可能是pg_notification_queue_usage()
, which tells you what fraction of the queue storage is currently used (out of 8GB in total in a standard installation, according to the NOTIFY
docs).
当然,内存使用量在很大程度上取决于负载,但如果您能计算出平均通知大小,您应该能够将其转换为近似队列长度。
问题标题说明了一切。我们在数据库 table 上设置了 TRIGGERS,该数据库正被异地工作人员使用。然而,有时工作人员似乎在更新记录方面落后了。是否有 SQL 查询或调用以确定消息的现有长度 queue? (不弹出任何项目)。我在 postgres 文档和 other Whosebug questions 中看到很多关于此 queue 的提及,但找不到任何关于实际确定长度的信息。感谢您的帮助!
对于那些熟悉 redis 的人,我正在寻找与此 postgres 消息 queue.
等效的LLEN
命令
我认为没有任何东西可以直接报告队列条目的数量。
最接近的可能是pg_notification_queue_usage()
, which tells you what fraction of the queue storage is currently used (out of 8GB in total in a standard installation, according to the NOTIFY
docs).
当然,内存使用量在很大程度上取决于负载,但如果您能计算出平均通知大小,您应该能够将其转换为近似队列长度。