[MDEV-31944] UPDATE creates new row in system-versioned tables even if there is no value to change Created: 2023-08-18 Updated: 2023-09-08 Resolved: 2023-09-05 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Versioned Tables |
| Affects Version/s: | 10.6.15 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Federico Razzoli | Assignee: | Sergei Golubchik |
| Resolution: | Not a Bug | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||
| Description |
|
UPDATE shouldn't do anything if the values I'm setting are identical to current values. But this is not the case with temporal tables. I create my system-versioned table:
I run the same INSERT ... ON DUPLICATE KEY UPDATE twice, and I'll have 2 fows.
The same happens if I run an UPDATE:
INSERT ... ON DUPLICATE KEY UPDATE is the logical way to implement a time-series-like workload. But the main advantage to do it in MariaDB with sysver tables is that storage is not supposed to grow until the values actually change, and avoid huge backups, frequent data rotation, etc. But this bug ruins the idea. |
| Comments |
| Comment by Sergei Golubchik [ 2023-09-05 ] |
|
This is intentional. At first, such updates were not creating historical rows and in the course of Indeed, SQL Standard does not have the language "if the new row was equal to the old row, then it's not really an UPDATE". There's no concept of comparing and old and new rows there, it's an optimization inside MariaDB. We can use this optimization only when it doesn't cause any user visible effects. But, for example, triggers are still run even if the row is updated to itself. And a new historical row has to be created too. |