akka / akka-persistence-r2dbc

https://doc.akka.io/docs/akka-persistence-r2dbc/current/index.html
Other
24 stars 17 forks source link

revision shouldn't be part of durable_state pk #558

Closed patriknw closed 5 months ago

patriknw commented 5 months ago
PRIMARY KEY(persistence_id, revision)

We don't ever want to store more than one row for a persistence_id. The application logic takes care of it, but would be good to have a correct primary key.

sebastian-alfers commented 5 months ago

I see that revision is also part of some indices for Durable State. Should we touch them as well?

johanandren commented 5 months ago

You mean the durable_state_slice_idx? Looking at the query it's not obvious that it is important, no filtering done on them a neither normal nor backtracking query could be satisfied by just looking at the index anyway. Maybe @patriknw knows something I don't though.

sebastian-alfers commented 5 months ago

If akka verifies that there is always only one revision for a given persistence_id, I can not imagine how that column can improve the index.

sebastian-alfers commented 5 months ago

Seems we have that index also here: https://doc.akka.io/docs/akka-projection/current/r2dbc.html

patriknw commented 5 months ago

I agree, shouldn't be needed in the index. Yes, please update akka-projection, we probably have ddl files in samples there also. and @efgpinto should update ddl in the Akka Guide

efgpinto commented 5 months ago

Just updated the script in the guide as well.