gpt4 book ai didi

mysql - 结果太慢,任何人都可以提供提升(查询工作文件中的 10 条记录,但需要时间来获取更多记录))

转载 作者:行者123 更新时间:2023-11-29 06:33:28 25 4
gpt4 key购买 nike

select a , b , c
from h1 where a in
(
select a
from h1
group by a
having count(distinct b) = 1
)

最佳答案

最有效的方法应该是不存在:

select h.a, h.b, h.c
from h1 h
where not exists (select 1
from h1 hh
where hh.a = h.a and hh.b <> h.b
);

为了提高性能,您需要在 h1(a, b) 上建立索引。

不需要聚合。

关于mysql - 结果太慢,任何人都可以提供提升(查询工作文件中的 10 条记录,但需要时间来获取更多记录)),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55084656/

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