admin管理员组文章数量:1122846
We have an extremely large S3 bucket, which is divided into folders by date. e.g.
- dt=2024-11-19
- dt=2024-11-20
- dt=2024-11-21
I run queries through Redshift, and was instructed to always filter by the dt field to keep costs down.
Now I'm trying to write a script that will dynamically query the last 2 days of data, and am wondering which method would be fastest/cheapest:
SELECT ... FROM src WHERE dt >= CAST(DATEADD (day,-1,GETDATE ()) AS DATE)
CREATE TEMPORARY TABLE var AS (SELECT CAST(DATEADD (day,-1,GETDATE ()) AS DATE) AS yday);
SELECT ... FROM src WHERE dt >= (SELECT yday FROM var)
CREATE TEMPORARY TABLE var AS (SELECT CAST(DATEADD (day,-1,GETDATE ()) AS DATE) AS yday);
SELECT ... FROM src JOIN var ON src.dt >= var.yday
Or is there a better way that I haven't thought of yet?
本文标签: sqlHow best to to dynamically query S3 foldersStack Overflow
版权声明:本文标题:sql - How best to to dynamically query S3 folders - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736301743a1931282.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论