Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 0DE3EEC7B26 for ; Fri, 6 Jul 2012 03:10:55 -0300 (ADT) Received: from mail.morefoo.com ([207.99.53.222]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Sn1ki-0004H2-B0 for pgsql-performance@postgresql.org; Fri, 06 Jul 2012 06:10:55 +0000 Received: from nac.morefoo.com (mail.morefoo.com [207.99.53.222]) by mail.morefoo.com (Postfix) with ESMTP id 4B1382D485A for ; Fri, 6 Jul 2012 02:10:38 -0400 (EDT) X-Virus-Scanned: amavisd-new at morefoo.com Received: from mail.morefoo.com ([207.99.53.222]) by nac.morefoo.com (nac.morefoo.com [207.99.53.222]) (amavisd-new, port 10024) with ESMTP id G1W-0+owm1zK for ; Fri, 6 Jul 2012 02:10:37 -0400 (EDT) Received: from toasty.sporklab.com (unknown [96.57.144.66]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: css@morefoo.com) by mail.morefoo.com (Postfix) with ESMTPSA id 554442D4859 for ; Fri, 6 Jul 2012 02:10:37 -0400 (EDT) Subject: select operations that generate disk writes From: CSS Content-Type: text/plain; charset=us-ascii Message-Id: Date: Fri, 6 Jul 2012 02:10:36 -0400 To: pgsql-performance@postgresql.org Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Apple Message framework v1084) X-Mailer: Apple Mail (2.1084) X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/45 X-Sequence-Number: 47226 Hello, Time for a broad question. I'm aware of some specific select queries = that will generate disk writes - for example, a sort operation when = there's not enough work_mem can cause PG to write out some temp tables = (not the correct terminology?). That scenario is easily remedied by = enabling "log_temp_files" and specifying the threshold in temp file size = at which you want logging to happen. I've recently been trying to put some of my recent reading of Greg's = book and other performance-related documentation to use by seeking out = queries that take an inordinate amount of time to run. Given that we're = usually disk-bound, I've gotten in the habit of running an iostat in a = terminal while running and tweaking some of the problem queries. I find = this gives me some nice instant feedback on how hard the query is = causing PG to hit the disks. What's currently puzzling me are some = selects with complex joins and sorts that generate some fairly large = bursts of write activity while they run. I was able to reduce this by = increasing work_mem (client-side) to give the sorts an opportunity to = happen in memory. I now see no temp file writes being logged, and = indeed the query sped up. So my question is, what else can generate writes when doing read-only = operations? I know it sounds like a simple question, but I'm just not = finding a concise answer anywhere. Thanks, Charles=