1

In RethinkDB, is it possible to create multiple indexes at once?
Something like (which doesn't work):

r.db('test').table('user').indexCreate('name').indexCreate('email').run(conn, callback)

1 Answer 1

1

Index creation is a fairly heavyweight operation because it requires scanning the existing documents to bring the index up to date. It's theoretically possible to allow creation of 2 indexes at the same time such that they both perform this process in parallel and halve the work We don't support that right now though.

However I suspect that's not what you're asking about. If you're just looking for a way to not have to wait for the index to complete and then come back and start the next one the best way would be to do:

table.index_create("foo").run(noreply=True)
# returns immediately
table.index_create("bar").run(noreply=True)
# returns immediately

You also can always do any number of writes in a single query by putting them in an array like so:

r.expr([table.index_create("foo"), table.index_create("bar")]).run()

I can't actually think of why this would be useful for index creation because index writes don't block until the index is ready but hey who knows. It's definitely useful in table creation.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, As you expected, I'm going to use them in table creation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.