Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres optimize for insert/read only

Tags:

sql

postgresql

I'm working on a database with the following characteristics:

  • Many inserts (in the range of 1k/second)
  • Lots of indices on the data, complex joins
  • NO Deletes or updates, only inserts, read and table drops
  • I don't care if the reads to the database reflect accurate state
  • Data isn't critical, I'm already running fsync=off

I already know a fair bit about postgres optimization, but I was hoping there might be some additional tricks that are more suited to my particular use case.

like image 249
drewrobb Avatar asked Oct 11 '22 22:10

drewrobb


2 Answers

You can disable the WAL, perhaps by pointing it to /dev/null or RAMDISK. Note there is some speculation that you may not be able to restart the DB after even a clean stop, so I advise caution and testing.

Make sure you cluster your tables. Partitioning might help as well.

Certainly disable synchronous_commits.

http://wiki.postgresql.org/wiki/FAQ#How_do_I_tune_the_database_engine_for_better_performance.3F

like image 104
Seth Robertson Avatar answered Oct 17 '22 02:10

Seth Robertson


You might want to use unlogged tables (available as of 9.1) for that. It's basically a table for which the WAL is disabled.

like image 26
Guilherme Salgado Avatar answered Oct 17 '22 04:10

Guilherme Salgado