How could one duplicate the same environment configuration as a database server?

StackOverflow https://stackoverflow.com/questions/23633372

  •  21-07-2023
  •  | 
  •  

Pregunta

I'm interested in making my local postgres server config match the production one. Given a psql connection to it, would it be possible to run some queries and extract the relevant performance options? Alternatively, if this is not possible, does anyone know the configuration options for heroku's paid postgres plans?

¿Fue útil?

Solución

This will show you all settings for the server.

SELECT current_setting(name), * FROM pg_catalog.pg_settings

Then you can look at the postgresql.conf to see what has been set manually.

If you don't have any access to the postgresql.conf, use the above query on some other server and see what's different :)

Otros consejos

This should work as long as you have permission to read the remote config file (change the delimiter at a pinch).

create table conf(
  line text
);

do $$ 
begin
  execute 
    format(
      'copy conf from ''%s'' delimiter ''|''', 
      current_setting('config_file'));
end $$;

select * from conf;

Two maybe helpful tips.

-- skip empty and commented lines:

select line from conf
where line != '' and ltrim(line, e' \t') not like '#%';

-- copy conf to file:

copy (select replace(line, e'\t', '    ') from conf) to 'c:/data/postgres.conf';
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top