For time series data, a powerful function is asof pioneered in kx/kdb, also being implemented by Pandas:
http://pandas.pydata.org/pandas-docs/version/0.19.0/whatsnew.html#whatsnew-0190-enhancements-asof-merge
It would be really cool if Timescaledb could support it natively instead of having write 3 tricky queries to join two time series tables.
Definitely an analytical function on our short list. Thanks for the request.
(And if others would similar like this, please upvote!)
Hi, is there an update on support for an As Of Join. I am looking to test out various Timeseries solutions and AsOf is something we would really like to support.
@mfreed
Hi,
any plan for this feature?
It is major point for financial (tick) data use case, so it can help to adopt timescale in this niche..
Another reference from leading db used in this market..: https://code.kx.com/wiki/Reference/aj
Thanks!
I agree. Having a performant global "AS OF" on a traditional RDMS like postgres would be a holy grail. Maintaining history today with postgres is, hmm, painful. This alone has made me seriously consider using Datomic (https://docs.datomic.com/on-prem/clojure/index.html#datomic.api/as-of). A dream query for me would be writing:
SELECT foo.id, bar.baz, sup.sop FROM foo
JOIN bar ON ...
JOIN sup ON ...
WHERE ...
LIMIT By 42
AS OF 2017-11-12
and getting the state of the world from that datetime. I realise this is moving from time series and into another territory which might not be a good fit for timescaledb. But a man can hope :)
Any updates or best practices?
This seems to be a possibility?
https://dba.stackexchange.com/posts/185372/revisions
This is the best I've managed to get so far:
SELECT * FROM table_a
CROSS JOIN LATERAL (
SELECT * FROM table_b
WHERE (
...
AND
table_a.time > table_b.time
)
ORDER BY table_b.time DESC LIMIT 1
) lookup
ORDER BY table_a.time;
Still not very performant though, takes >1s on two tables of ~200k rows (pandas can do it >50x faster).
Are there any plans to add this? Would be a really big deal for financial applications, among many others
+1
Any update here? Is there an ETA for as-of join support?
Very under the (my) radar, mariaDB suddenly has very cool looking support for AS OF time machining:
@runekaagaard thanks, so no ETA?
Just to be crystal clear: We are referring to as-of joins and not AS OF for data versioning.
Good example for AS OF JOINS is here: https://pandas.pydata.org/docs/reference/api/pandas.merge_asof.html --> see bottom of that page which illustrates how to join market trades & quotes
The kdb+ equivalent command is "aj", see https://code.kx.com/q/ref/aj/
If I misunderstood the purpose of this issue here, let me know and I'm happy to open another one
The addition of as-of joins within Timescale would be a huge benefit to us. We have lots of high frequency time series datasets from environmental sensors that have slightly differing timestamps (at the ms scale) and occasional gaps. Our requirements are pretty much met by the functionality described in the pandas.merge_asof documentation but it would be great if we could do the same sort of thing at the database level. A possible addition would be to allow for aligning the sensor time series datasets against a strict timeline (e.g. every exact second, minute etc.).
Most helpful comment
Definitely an analytical function on our short list. Thanks for the request.
(And if others would similar like this, please upvote!)