Postgres very slow on server
Looking at your server times: 23 seconds to restore a table with 1,6 million rows from a 1.8 GB dump file. That does not seem too bad. Might be faster, but doesn't seem very slow either.

To speed up index creation (as well as UNIQUE and PK constraints) set maintenance_work_mem high enough temporarily (for the local session or transaction only). The manual:


  maintenance_work_mem (integer)
  
  ... Specifies the maximum amount of memory to be used by maintenance operations, such as VACUUM, CREATE INDEX, and ALTER TABLE ADD FOREIGN KEY.
  It defaults to 64 megabytes (64MB).


Set it just high enough for Postgres to process everything in RAM (If you have enough RAM to spare (temporarily). For instance:

BEGIN;
SET LOCAL maintenance_work_mem = 1GB;  -- adapt to your needs
ALTER TABLE testtable ADD CONSTRAINT testtable_lang_q_key UNIQUE (lang, q);
COMMIT;


The manual warns:


  Note that when autovacuum runs, up to autovacuum_max_workers times
  this memory may be allocated, so be careful not to set the default
  value too high.


Setting it high for your transaction only avoids this problem.

Related:


Is a clustered index on column A the same as creating a table ordered by A?