gpt4 book ai didi

postgresql - Postgres效率

转载 作者:行者123 更新时间:2023-11-29 12:06:44 24 4
gpt4 key购买 nike

假设我有一个表,其中包含一些 key 、帐户和点击数。

哪个更快?我想我的问题是 postgres(或与此相关的任何 sql)是否有一个智能优化器可以在查询中查看相同的函数

SELECT key, accounts, hits,1.0*hits/accounts as ratio FROM
(
SELECT key, COUNT(DISTINCT accounts) as accounts, SUM(hits) as hits
FROM table
GROUP BY key
) a;

SELECT key, COUNT(DISTINCT accounts) as accounts, SUM(hits) as hits, 1.0*SUM(hits)/COUNT(DISTINCT accounts) as ratio
FROM table
GROUP BY key;

我很想听听您在理解这类事情时必须说的任何内容或可以提供的资源。谢谢!

最佳答案

是的,是的。这就是函数波动性的作用。

http://www.postgresql.org/docs/current/static/sql-createfunction.html

请参阅 volatile 与稳定与不可变。

关于postgresql - Postgres效率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5980705/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com