If / as we move to analytic workloads it would be awesome to see postgres pickup support for AsOf, time_bucket, etc that duckdb and timescale have.<p>I don't and never have enjoyed SQL and I much prefer the ergonomics of time_bucket to date_bin.<p>For example, I would do this in duckdb:<p><pre><code> SELECT
count(*) as y
, time_bucket(interval '2 weeks', at::timestamp) as x
FROM analytics
WHERE some_bool AND some_haystack = 'needle'
GROUP BY x
ORDER BY x
</code></pre>
In postgres it looks more like:<p><pre><code> with counts as (
SELECT
date_bin('1 hour'::interval, at, (now() - interval '2 weeks')::timestamp)
, count(*) c
FROM analytics a
WHERE some_bool AND some_haystack = 'needle'
GROUP BY date_bin
)
select series as x, coalesce(counts.c, 0) as y
from generate_series(
(now() - interval '2 weeks')::timestamp,
now()::timestamp,
interval '1 hour'
) series
LEFT JOIN counts
ON counts.date_bin = series;</code></pre>