Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id A09281D3FDDA for ; Thu, 1 Mar 2012 21:13:52 -0400 (AST) Received: from [2001:1528:137::f1] (helo=mail.gransy.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S3H4A-0006bp-8m for pgsql-performance@postgresql.org; Fri, 02 Mar 2012 01:13:51 +0000 Received: from antispam.gransy.com (antispam.gransy.com [77.78.104.124]) by mail.gransy.com (Postfix) with ESMTP id 794C14A200B; Fri, 2 Mar 2012 02:13:36 +0100 (CET) Received: from mail.gransy.com ([82.208.29.194]) by antispam.gransy.com (antispam.gransy.com [77.78.104.124]) (amavisd-new, port 10024) with ESMTP id LERDtoixddzJ; Fri, 2 Mar 2012 02:13:36 +0100 (CET) Received: by mail.gransy.com (Postfix, from userid 5000) id 681174A2038; Fri, 2 Mar 2012 02:13:36 +0100 (CET) Received: from [192.168.1.237] (ip-78-45-133-255.net.upcbroadband.cz [78.45.133.255]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.gransy.com (Postfix) with ESMTPSA id 46F5C4A200B; Fri, 2 Mar 2012 02:13:36 +0100 (CET) Message-ID: <4F501EC0.6070801@fuzzy.cz> Date: Fri, 02 Mar 2012 02:13:36 +0100 From: Tomas Vondra User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20120129 Thunderbird/10.0 MIME-Version: 1.0 To: Claudio Freire CC: "pgsql-performance@postgresql.org" Subject: =?UTF-8?B?UmU6IFtQRVJGT1JNXSBSZTogW1BFUkZPUk1dIFJlOiBbUEVSRk9STV0=?= =?UTF-8?B?IFJlOiBbUEVSRk9STV0gUmU6IOWbnuWkje+8miBbUEVSRk9STV0gUEcgYXMgaW4=?= =?UTF-8?B?LW1lbW9yeSBkYj8gSG93IHRvIHdhcm0gdXAgYW5kIHJlLXBvcHVsYXRlIGJ1ZmY=?= =?UTF-8?B?ZXJzPyBIb3cgdG8gcmVhZCBpbiBhbGwgdHVwbGVzIGludG8gbWVtb3J5Pw==?= References: <1330346798.90731.YahooMailNeo@web30808.mail.mud.yahoo.com> <8da9b15646d973a5ee23ba49faeee8fd.squirrel@sq.gransy.com> <347477cf700da0b19ad62b50cae5ae1c.squirrel@sq.gransy.com> <7993f32e79b113a0ca3de4d9e500d106.squirrel@sq.gransy.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:1528:137::f1 (failed) X-Pg-Spam-Score: -1.1 (-) X-Archive-Number: 201203/38 X-Sequence-Number: 46488 On 28.2.2012 17:42, Claudio Freire wrote: > On Tue, Feb 28, 2012 at 1:05 PM, Tomas Vondra wrote: >> On 28 =C3=9Anor 2012, 15:24, Claudio Freire wrote: >>> It speeds a lot more than the initial load of data. >>> >>> Assuming the database is read-only, but not the filesystem (ie: it's >>> not a slave, in which case all this is moot, as you said, there are n= o >>> writes on a slave). That is, assuming this is a read-only master, the= n >>> read-only queries don't mean read-only filesystem. Bookkeeping tasks >>> like updating catalog dbs, statistics tables, page cleanup, stuff lik= e >>> that can actually result in writes. >>> >>> Writes that go through the WAL and then the filesystem. >> >> I'm not sure what maintenance tasks you mean. Sure, there are tasks th= at >> need to be performed after the load (stats, hint bits, updating system >> catalogs etc.) but this may happen once right after the load and then >> there's effectively zero write activity. Unless the database needs to >> write temp files, but that contradicts the 'fits into RAM' assumption = ... >=20 > AFAIK, stats need to be constantly updated. Err, what kind of stats are we talking about? Statistics capturing characteristics of the data or runtime stats? There's no point in updating data stats (histograms, MCV, ...) for read-only data and PostgreSQL doesn't do that. Runtime stats OTOH are collected and written continuously, that's true. But in most cases this is not a write-heavy task, and if it is then it's recommended to place the pg_stat_tmp on ramdrive (it's usually just few MBs, written repeatedly). > Not sure about the rest. AFAIK it's like this: updating catalog tables - no updates on read-only data updating statistics - data stats: no, runtime stats: yes page cleanup - no (just once after the load) > And yes, it's quite possible to require temp files without a database > that doesn't fit in memory, only big OLAP-style queries and small > enough work_mem. Right. I'm not exactly sure how I arrived to the crazy conclusion that writing temp files somehow contradicts the 'fits into RAM' assumption. That's clearly nonsense ... >=20 >> The writes are always carried out by the OS - except when dirty_ratio = is >> exceeded (but that's a different story) and WAL with direct I/O enable= d. >> The best way to allow merging the writes in shared buffers or page cac= he >> is to set the checkpoint_segments / checkpoint_timeout high enough. >> That way the transactions won't need to wait for writes to data files >> (which is the part related to evictions of buffers from cache). And >> read-only transactions won't need to wait at all because they don't ne= ed >> to wait for fsync on WAL. >=20 > Exactly >=20 >>> In essence, what was required, to keep everything in RAM for as much >>> as possible. >>> >>> It *does* in the same way affect buffer eviction - it makes eviction >>> *very* quick, and re-population equally as quick, if everything fits >>> into memory. >> >> No it doesn't. Only a write caused by a background process (due to ful= l >> shared buffers) means immediate eviction. A simple write (caused by a >> checkpoint) does not evict the page from shared buffers. Not even a >> background writer evicts a page from shared buffers, it merely marks t= hem >> as 'clean' and leaves them there. And all those writes happen on the >> background, so the clients don't need to wait for them to complete (ex= cept >> for xlog checkpoints). >=20 > So, we're saying the same. Maybe. I still am not sure how fsync=3Doff affects the eviction in your opinion. I think it does not (or just very remotely) and you were saying the opposite. IMHO the eviction of (dirty) buffers is either very fast or slow, no matter what the fsync setting is. > With all that, and enough RAM, it already does what was requested. >=20 > Maybe it would help to tune shared_buffers-to-os-cache ratio, and > dirty_ratio to allow a big portion of RAM used for write caching (if > there were enough writes which I doubt), but, in essence, un > unmodified postgres installation with enough RAM to hold the whole DB > + shared buffers in RAM should perform quite optimally. Probably, for a read-write database that fits into memory. In case of a read-only database I don't think this really matters because the main issue there are temp files and if you can stuff them into page cache then you can just increase the work_mem instead and you're golden. Tomas