Re: [GENERAL] Request to confirm which command is use for exclusiveoperation - Mailing list pgsql-general

From Albe Laurenz
Subject Re: [GENERAL] Request to confirm which command is use for exclusiveoperation
Date
Msg-id A737B7A37273E048B164557ADEF4A58B53A0691D@ntex2010i.host.magwien.gv.at
Whole thread Raw
In response to Re: [GENERAL] Request to confirm which command is use for exclusive operation  (Yogesh Sharma <yogeshraj95@gmail.com>)
Responses Re: [GENERAL] Request to confirm which command is use for exclusive operation
List pgsql-general
Yogesh Sharma wrote:
>  I want to apply explicitly lock mechanism once inset operation is in progress then REINDEX will wait.
> And vice versa.
> So, please let me know this type of handling is possible.

Maybe I misunderstand something, but you don't need to do that because it
happens automatically.

If you run REINDEX, it will take an ACCESS EXCLUSIVE lock on the index
before it starts its work.

That means that it has to wait until all earlier INSERTing transactions are
ended, and all INSERTs that come after the REINDEX will have to wait until
the REINDEX is done.

The database takes care that the data are consistent, so why would you
want to do that explicitly?

Yours,
Laurenz Albe

pgsql-general by date:

Previous
From: Günce Kaya
Date:
Subject: [GENERAL] import CSV file to a table
Next
From: Albe Laurenz
Date:
Subject: Re: [GENERAL] Postgres, apps, special characters and UTF-8 encoding