Re: Foreign key creation on table with huge record count.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> On Jan 30, 2023, at 1:12 PM, Gambhir Singh <gambhir.singh05@xxxxxxxxx> wrote:
> 
> do we have parallel hint like option in postgreSQL as there in Oracle. 

I don't know of a hint option you can put on a query. But if you are running a recent enough version of PG, there are options to support parallel queries, and you can tune up number of workers etc. I don't actually know if it can use multiple workers on constraint creation, but you can use "explain" on your command to create the constraint, to see if the planner will be using parallel workers.

Of course make sure that the field being referred to is indexed, in other words given

col1 references table2(col2)

make sure col2 is indexed

Is this operation effectively taking your database out of service while it runs? If so, then you can temporarily use a config tuned for just this: let work mem for this one connection use up a big % of RAM, use multiple workers etc. In some cases I've even turned fsync off--this means if you crash you could wind up with a corrupted database, but if you have a current backup, then you either succeed and turn fsync back on when you're done, or you have your backup if something bad happens.





[Index of Archives]     [Postgresql Home]     [Postgresql General]     [Postgresql Performance]     [Postgresql PHP]     [Postgresql Jobs]     [PHP Users]     [PHP Databases]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Forum]

  Powered by Linux