gpt4 book ai didi

mysql - SQL语句运行缓慢

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

我在从日志表加载数据时遇到问题。我正在尝试过滤具有字符串的列上的表。以下是我正在使用的声明。我最多可以提取 4 周前的数据,但是当我尝试提取更多历史数据时,它会超时。我已经将时间延长到600秒,但仍然出现同样的错误。所以我想有更好的方式来写我的陈述吗?

此外,如果可能的话,我希望获得基于该值的最新时间戳

提前感谢您。乔

select 
dl.user_id,
dl.timestamp,
dl.value,
dl.operation,
concat(concat(un.first_name, ' '), un.last_name) AS "User" ,
from data_log dl
where dl.timestamp >= date '2019-12-01' and dl.operation = 'update' and dl.values like
'%"date_time"%'

最佳答案

对于此查询:

select dl.user_id, dl.timestamp, dl.value, dl.operation,
concat(concat(un.first_name, ' '),
un.last_name) AS "User"
from data_log dl
where dl.timestamp >= date '2019-12-01' and
dl.operation = 'update' and
dl.values like '%"date_time"%';

您想要在data_log(操作、时间戳、值)上建立索引。这可能有助于解决性能问题。

关于mysql - SQL语句运行缓慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59659629/

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