How to do it...

Follow these steps to test concurrent index creation:

  1. Connect to the pgbench database and execute the following command as a superuser or the postgres user:
        CREATE INDEX CONCURRENTLY idx_account_bid 
            ON pgbench_accounts (bid); 
  1. In another connection, attempt to execute the following insert before the preceding command completes:
        INSERT INTO pgbench_accounts 
        VALUES (50000000, 100, 15000, 'testing'); 

Get PostgreSQL High Availability Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.