我的大多数查询最多在 3 秒内完成。即使它们要复杂得多。这个需要很长时间(至少我在 10 分钟后就退出了):
UPDATE public.url
SET
last_seen_on = NOW()
FROM public.temp_url AS B
INNER JOIN public.url AS A
ON A.url_path = B.url_path;
查询有问题吗?我没有收到任何错误消息。 解释一下:
Update on url (cost=28512.96..4035340577.80 rows=0 width=0)
-> Nested Loop (cost=28512.96..4035340577.80 rows=188508798976 width=26)
-> Hash Join (cost=28512.96..53744.52 rows=434176 width=12)
Hash Cond: (b.url_path = a.url_path)
-> Seq Scan on temp_url b (cost=0.00..12641.82 rows=434182 width=43)
-> Hash (cost=19269.76..19269.76 rows=434176 width=42)
-> Seq Scan on url a (cost=0.00..19269.76 rows=434176 width=42)
-> Materialize (cost=0.00..23136.64 rows=434176 width=6)
-> Seq Scan on url (cost=0.00..19269.76 rows=434176 width=6)
JIT:
Functions: 13
Options: Inlining true, Optimization true, Expressions true, Deforming true
很可能不是正确的查询,因为您使用
url
两次并且没有条件。
我最好的选择是你需要这个查询:
UPDATE public.url
SET
last_seen_on = NOW()
FROM public.temp_url
WHERE url.url_path = temp_url.url_path;
两列上的索引
url_path
可能会有好处。