Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you calculate the time to create an index on a large Postgresql table?

I have a Postgres table with 26 million rows in it, and I want to add an indexed boolean column.

Is there a way to calculate how long that type of operation will take, before attempting it in production?

like image 661
Carolyn Conway Avatar asked Aug 17 '16 17:08

Carolyn Conway


People also ask

How long does it take to create an index on a large table Postgres?

I followed this guide to pick the parameters: https://www.cybertec-postgresql.com/en/postgresql-parallel-create-index-for-better-performance/. This sped up the index creation and it only took 35 hours. Shaving off 10 hours was a nice surprise. Thanks!

How long does it take to create an index on a large table?

The table is partitioned into 40 pieces on column text . Then creating index on the table takes about 1 hours to complete.

How long does it take to make an index?

Although it varies, it seems to take as little as 4 days and up to 6 months for a site to be crawled by Google and attribute authority to the domain. When you publish a new blog post, site page, or website in general, there are many factors that determine how quickly it will be indexed by Google.

How long does it take to index a database?

If you are just adding the single index, it should take about 10 minutes. However, it will take 100 minutes or more if you don't have that index file in memory. Your 200 varchar with 8 million rows will take a maximum of 1.6GB, but with all of the indexing overhead it will take about 2-3 GB.


1 Answers

There is no way to calculate index time as it depends on many factors (hardware, software, configuration, load, etc.)

The good news is that you may CREATE INDEX CONCURRENTLY, which takes longer but does not lock the table. So the operation has no side effects except higher load on server.

For some caveats, check the documentation.

like image 84
user3621424 Avatar answered Oct 19 '22 02:10

user3621424