我正在寻找有关以下Postgres查询的优化建议。不是DBA,因此请在此处寻求专家建议。
Devices表包含十六进制的device_id。 为了实现高吞吐量,我们并行运行此查询的6个实例以及device_id的模式匹配 以[0-2],[3-5],[6-9],[a-c],[d-f]开头
当我们仅运行查询的一个实例时,它可以正常工作,但是在6个实例中,我们会遇到错误- [6669]:致命:与客户端的连接丢失
CallScreen.cshtml
解释分析的输出
explain analyze select notifications.id, notifications.status, events.alert_type,
events.id as event_id, events.payload, notifications.device_id as device_id,
device_endpoints.region, device_endpoints.device_endpoint as endpoint
from notifications
inner join events
on notifications.event_id = events.id
inner join devices
on notifications.device_id = devices.id
inner join device_endpoints
on devices.id = device_endpoints.device_id
where notifications.status = 'pending' AND notifications.region = 'ap-southeast-2'
AND devices.device_id ~ '[0-9a-f].*'
limit 10000;