Schedule REINDEX table CONCURRENTLY job

1.2k Views Asked by At

Aurora Postgress 12.6 Purpose: schedule to rebuild all indexes. what I did is create a function that calls all tables names and reindex concurrently and put the function in pg_cron but it gives me the error "SQL Error [25001]: ERROR: REINDEX CONCURRENTLY cannot be executed from a function". How can I archive the purpose?

Thanks

1

There are 1 best solutions below

9
On BEST ANSWER

Don't do it. There is usually never a need to rebuild indexes.

You can test the indexes regularly using pgstatindex from the pgstattuple extension if you are worried.