Open jeroiraz opened 3 years ago
This is a a very good point and will be very usefull for me :). Thank you for open the feature request!
Do immudb row versions have start and end timestamp? If so, I'd recommend using the standard SQL(1) syntax for system-period tables(2) instead. MariaDB page is simple, with several examples, but major DBMSs implement more or less the same syntax: https://mariadb.com/kb/en/system-versioned-tables/#
This would allow several advantages:
All tables could be system-versioned. In the case of immudb, a user shouldn't have to use any special syntax when a table is created.
(1) Actually I don't know if it is standard SQL or just a de facto standard feature. (2) Please note that I'm proposing system-period tables, not application-period tables.
Hi @jeroiraz ,
SELECT * FROM (N? (FORWARD|BACKWARD)? UPDATES (OFFSET M)? AT mytable)
That query approach looks good. What if we use alternative more aligned with existing sql
SELECT * FROM products WHERE id = 1 LIMIT 1 BACKWARD|FORWARD OFFSET 0;
Other than that, I'm wondering how this approach deal with table joins?
Hi @jeroiraz ,
SELECT * FROM (N? (FORWARD|BACKWARD)? UPDATES (OFFSET M)? AT mytable)
That query approach looks good. What if we use alternative more aligned with existing sql
SELECT * FROM products WHERE id = 1 LIMIT 1 BACKWARD|FORWARD OFFSET 0;
Other than that, I'm wondering how this approach deal with table joins?
thanks @iambudi for the feedback.
In the grammar BACKWARD|FORWARD clauses are close to the data source, as it's specifying how to scan over it. And it will be simpler to implement historical queries over physical tables.
Then joins will work as usual but taking into account that the rows fetched from the datasource may contain the same primary key multiple times, once per row update in the specified historical range...
@jeroiraz thank you, it makes sense. Hope the implementation will soon be started :)
Hi, i'm curious if this feature has already been started and have ETA? Thank you.
What would you like to be added or enhanced
immutability provides a new perspective about changes, actually immutability makes changes explicit as no in-place mutations are made but appended. The final state may be interpreted as the latest appended change or in general, as a function of all updates made to a same entity.
Note: immudb is not just immutable but cryptographically verifiable.
At the SQL layer, immudb provides a special statement for updating rows based on its primary key i.e.
UPSERT
Currently, it's only possible to query the latest row state using standard SQL grammar thus providing a way to query historical row values may be required in order to fetch all the updates made to a given row.
The following illustrative examples may describe a possible approach to solve this problem: