-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query at time across multiple tables #37
Comments
Hi @jamiewinder, That idea does have legs. It was one of the two ideas I considered implementing. The other one was specifying the system time as a comment near the table it relates to, as in SELECT * FROM subscriptions /* AS OF SYSTEM TIME '2014-01-10' */ WHERE id = 1; I know a little about how the system time concept is implemented in SQL Server. I used IBM DB2 as a reference implementation, but as far as I can remember, the The main problem with introducing a function like In order not to repeat the CREATE VIEW my_view
SELECT ... FROM subscriptions
INNER JOIN products ON products.sys_period && subscriptions.sys_period AND ...
INNER JOIN publishers ON publishers.sys_period && subscriptions.sys_period AND ... Then you could do something like: SELECT * FROM my_view WHERE sys_period @> '2015-01-10'::timestamptz |
That's great, thanks! I think I assumed incorrectly about AS OF SYSTEM TIME (i.e. that it was for all tables in the query). Now you've pointed it out it makes sense that it isn't always something you'd want to do. Would putting the AS OF clause in a comment like the example you gave actually apply the clause in the example you gave? Sounds like a great idea if so! I'll investigate the view idea you gave - I am still getting used to these range operators! Thanks again. |
No, not at the moment. |
Hi. I'm new to this extension and PostgreSQL in general. I know a little about temporal tables from SQL Server and have been investigating how viable it would be to port my database over.
From this tutorial, I know the standard syntax isn't supported:
and instead we can use a view:
This is fine for a single table, but if I were joining to another temporal table I'd have to repeat the sys_period clause for every temporal view. I'm wondering if there is a more elegant way to do this? Perhaps a view like:
Where
get_temporal_query_time
would have an equivalentset_temporal_query_time
. This would mean I could do something like:As far as I can see, this is similar to the existing
set_system_time
utility, but for querying rather than versioning. Does this idea have legs?The text was updated successfully, but these errors were encountered: