There's more…

You can change the value of a setting during your transaction as well, like this:

SET LOCAL work_mem = '16MB';

This results in the following output:

WARNING:  SET LOCAL can only be used in transaction blocks
SET

In order to understand what the warning means, we look that setting up in the pg_settings catalog view:

postgres=# SELECT name, setting, reset_val, source 
FROM pg_settings WHERE source = ‘session’;
name | setting | reset_val | source
----------+---------+-----------+---------
work_mem | 1024 | 1024 | session

Huh? What happened to your parameter setting? The SET LOCAL command takes effect only for the transaction in which it was executed, which was just the SET LOCAL command in our case. We need to execute it inside a transaction block to be able to see the setting take hold, as follows:

BEGIN; 
SET LOCAL work_mem = '16MB';

Here is what shows up in the pg_settings catalog view:

postgres=# SELECT name, setting, reset_val, source
FROM pg_settings WHERE source = 'session';
name | setting | reset_val | source
----------+---------+-----------+---------
work_mem | 16384 | 1024 | session

You should also note that the value of source is session rather than transaction, as you might have been expecting.