7

I know CREATE INDEX CONCURRENTLY is slower, but how many longer it will takes to finish in comparison with the traditional CREATE INDEX? 40% more or much more than that?

I am creating an index in a table with 10000 registers, and in a column with 15 chars. It is taking 10 minutes using the traditional CREATE INDEX.

I know it is very difficulty to answer that, but there is a way to estimate?

András Váczi
31.8k13 gold badges103 silver badges152 bronze badges
asked May 25, 2016 at 14:47

2 Answers 2

3

2ndQuadrant says:

[CREATE INDEX CONCURRENTLY] must wait for all existing transactions to finish before starting the second phase on index build. This guarantees that no new broken HOT chains are created after the second phase begins.

I've seen CREATE INDEX CONCURRENTLY take over 90 seconds (before I aborted it) when creating the same index not CONCURRENTLY took 0.5 seconds. So it can be much slower.

There was no write activity on the table in the mean time, but other transactions were open on other tables. I think 2ndQuadrant mean that all transactions must end, not just those which have already written to the table in question.

answered Jul 18, 2018 at 8:48
3

It depends on the activity on the table. It there is no activity then there should be no difference.

answered May 25, 2016 at 14:49
2
  • 1
    "If there is no activity there should be no difference.." So what you're saying is that create index concurrently is always a good idea? Because if i have activity in the database i don't wanna to use the traditional create index im right? And in the other way(no activity) they will be identical so the traditional option will make no difference.... is that true? Commented May 25, 2016 at 14:51
  • 2
    Yes. In a production database you want to avoid locks on the table to ensure that the index creation does not disturb other users. Of course the creation will be slower but in prod the main goal is to keep things going then to finish admin tasks quicker. In dev or test you can chose what ever you like more. Commented May 25, 2016 at 14:56

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.