0

I have a problem. I am learning PostgreSQL and I work with pgAdmin 4v4. At this point, I am trying to set PostgreSQL to use as buffers more RAM than my computer has. I am thinking of using something like SET shared_buffers TO '256MB' but I am not sure if it is correct. Do you have any ideas?

theduck
  • 2,589
  • 13
  • 17
  • 23
A.Chatz
  • 3
  • 4
  • 1
    Why would you want to do that? –  Dec 04 '19 at 13:40
  • I want to check the difference in times of executing some queries before and after that. – A.Chatz Dec 04 '19 at 13:43
  • 2
    Why would you ever want to do that? It would mean that the DBMS would spend all of its time waiting for the OS to move things in and out of the swap file. The difference in queries would be absolutely meaningless, because the swap file overhead would take up all the time. – Ken White Dec 04 '19 at 13:43
  • But 256MB surely is less RAM than your computer has. I don't understand. – Laurenz Albe Dec 04 '19 at 14:04

1 Answers1

1

SET shared_buffers TO '256MB'

This will not work because shared_buffers must be set at server start and cannot be changed later, and this is a command you would run after the server is already running. You would have to put the setting in postgresql.conf, or specify it with the -B option to the "postgres" command.

You could also set it through 'alter system' command, and it would take effect at the next restart. However, you could easily make it a setting that will cause your system to fail to start again (indeed, that appears to be your goal...), at which point you can't use 'alter system' to fix it, and will have to dig into the .conf files.

jjanes
  • 37,812
  • 5
  • 27
  • 34