Re: select max(field) from table much faster with a group by clause?

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Palle Girgensohn" <girgen(at)pingpong(dot)net>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, <pgsql-performance(at)postgresql(dot)org>
Subject: Re: select max(field) from table much faster with a group by clause?
Date: 2007-11-01 15:47:32
Message-ID: 873avqrmqz.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance


"Palle Girgensohn" <girgen(at)pingpong(dot)net> writes:

> Are there any other things I can modify?

You might consider an index on <userid,when>. Keep in mind that every new
index imposes an incremental cost on every update and insert and increases the
time for vacuum.

> max_prepared_transactions = 100 # can be 0 or more

Are you actually using prepared transactions (are you synchronising multiple
databases using a transaction manager)? If not then set this to 0 as it takes
some resources.

> maintenance_work_mem = 16384 # min 1024, size in KB

Raising this might decrease vacuum times if that's a problem.

> fsync = off

You realize that this means if the system loses power or the kernel crashes
you could have data corruption? Do you take very frequent backups or can you
reconstruct your data?

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's Slony Replication support!

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Steve Crawford 2007-11-01 16:20:46 Re: Hardware for PostgreSQL
Previous Message Tom Lane 2007-11-01 15:34:42 Re: select max(field) from table much faster with a group by clause?