Currently the only way to access process variables of ended processes are via the HistoricDetails. There all variables updates are stored. This is convenient in many ways:
If you want to do SQL queries / reports on ended variables, it is at least a two step approach to get the last variable and query the vaule. This cannot be achieved with a simple SQL
In mass scenarios this had a serious negative impact on performance
You are forced to store all process variable changes even if you are only interested in the last value when the process ends.
1.) Introduce an own HistoricProcessVariable which just captures always the last value
2.) Introduce a separate history level which writes variables but not variable changes.