How can I get last tuple in space?

Viewed 54

How can I get last tuple in space? Last tuple here is tuple with max primary key value

 local a = box.space.SPACE:len()
 box.space.SPACE:get{a}

This variant is not suitable because the number of tuples is not equal to the number of created indexes

1 Answers

The best way to get last tuple in your case is box.space.X.index[0]:max() or box.space.X.index[0]:select({MAX_INT}, {limit=1, iterator='LE"})[1], if you prefer...

Related