| At line 6 added 44 lines |
| !!TUNING |
| Per un tuning di base di postgres si può utilizzare questa utility: [pg-tune|http://pgfoundry.org/projects/pgtune/] |
|
| Per una macchina con circa 4GB una configurazione "decente" di postgres potrebbe essere questa: |
|
| %%prettify |
| {{{ |
| maintenance_work_mem = 288MB # pgtune wizard 2010-02-24 |
| checkpoint_completion_target = 0.7 # pgtune wizard 2010-02-24 |
| effective_cache_size = 3584MB # pgtune wizard 2010-02-24 |
| work_mem = 24MB # pgtune wizard 2010-02-24 |
| wal_buffers = 4MB # pgtune wizard 2010-02-24 |
| checkpoint_segments = 8 # pgtune wizard 2010-02-24 |
| shared_buffers = 960MB # pgtune wizard 2010-02-24 |
| max_connections = 200 # pgtune wizard 2010-02-24 |
| }}} |
| /% |
|
|
| Se si aumentano le connessioni e lo shared_buffers di postgres è possibile/probabile che serva aumentare anche la shared memory di linux questo è possibile attraverso questi comandi: |
| %%prettify |
| {{{ |
| cp /etc/sysctl.conf /etc/sysctl.conf-orig |
| vi /etc/sysctl.conf |
| }}} |
| /% |
|
| Aggiungere la riga con il valore appropriato: |
|
| %%prettify |
| {{{ |
| kernel.shmmax = 104857600 |
| }}} |
| /% |
|
| Salvare il file e far ricaricare i parametri al kernel con: |
|
| %%prettify |
| {{{ |
| sysctl -p |
| }}} |
| /% |
|
|
| At line 139 changed one line |
| pg_restore -U DBUSER -d DBNAME -t TABLE -v -Fc db.dump |
| pg_restore -c -U DBUSER -d DBNAME -t TABLE -v -Fc db.dump |
| ATTENZIONE: sulla singola tabella sembra che non ricrei gli indici (e quindi nemmeno le primary key) |
| At line 141 changed one line |
| pg_restore -U DBUSER -d DBNAME --schema=SCHEMA -v -Fc db.dump |
| pg_restore -c -U DBUSER -d DBNAME --schema=SCHEMA -v -Fc db.dump |
| At line 143 changed one line |
| pg_restore -U DBUSER -d DBNAME -Fc db.dump |
| pg_restore -c -U DBUSER -d DBNAME -Fc db.dump |
| At line 145 changed one line |
| L'opzione -c indica a pg_restore di eliminare le tabelle (drop).\\ |
| L'opzione -c indica a pg_restore di eliminare le tabelle (drop) e ricrearla.\\ |
| At line 163 changed one line |
| !!Import di dati |
| !!Import/export di dati |
| At line 166 changed one line |
| copy SCHEMA.TABLE from 'TABLE.txt' using delimiters ',' CSV; |
| export da pslq |
| \f ',' |
| \a |
| \t |
| \o outputfile.csv |
| select ..... (your sql select statement) |
| \o |
|
| import da psql |
| copy SCHEMA.TABLE from 'TABLE.vsc' using delimiters ',' CSV; |
|
| se in fase di import (copy) da comando di linea (psql) ottieni un errore tipo |
| ERROR: must be superuser to COPY to or from a file |
|
| usare da linea di comando linux |
| cat TUOFILE.csv | psql -U DBUSER -d DBNAME -c "copy SCHEMA.TABLE from stdin delimiter ',' CSV"; |