Can there be any problems deleting records when iterating over them in Tarantool?

Viewed 75

Capture this:

for _, t in box.space.session.index.user:pairs({uid}) do
    local session_id = t[F.session.id]
    box.space.session:delete({session_id})
end

Can there be any performance or correctness problems?

Tarantool 1.9

1 Answers

It's totally fine. However, be advised of the following:

  • if you don't use transactions, you may or may not walk over records that are being inserted while you're iterating over space.
  • adding transactions would boost performance
  • but, transactions that consist of more than several thousand records may freeze tarantool for too long, so final decision depends on your typical load
Related