Group most recent documents by key

As you never used db2 , you no need join. Also if you want only eventType = “identification”, the following is right query and index

SELECT MAX([db1.payload.time, db1])[1] AS d
FROM statedb AS db1 
WHERE db1.eventType = "identification"
GROUP BY db1.payload.personalID
ORDER BY d.payload.personalID;
CREATE INDEX ix1 ON statedb(eventType);

MAX([db1.statedb.payload.time, db1]) ==> If you look argument of MAX it is array with 0th position is db1.statedb.payload.time, 1st position is whole document.
When MAX is calculated it calculates on ARRAY, When 0th element MAX , when 0th element is equal then 1st element like that.
As MAX produces ARRAY then [1] gives 1st element which is whole document.
This is approach is hidden advantage in N1QL for both MAX, MIN

Also check this post further optimize first do get META().id for groups and then fetch whole document

The following will perform better

CREATE INDEX ix1 ON statedb( payload.time, payload.personalID ) WHERE eventType = "identification";
SELECT d.* FROM (SELECT  RAW (MAX([payload.time,META().id])[1])
                  FROM stagedb
                  WHERE eventType = "identification" AND payload.time IS NOT NULL
                  GROUP BY payload.personalID) AS q
JOIN stagedb AS d ON KEYS q
ORDER BY d.payload.personalID;

If you want on specific times you can change the predicate payload.time IS NOT NULL.
NOTE: You need to have predicate on leading index key to choose the index.