Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 01CB1118883B for ; Tue, 17 Jul 2012 00:31:18 -0300 (ADT) Received: from mail-yw0-f46.google.com ([209.85.213.46]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SqyVI-0005iA-Kb for pgsql-performance@postgresql.org; Tue, 17 Jul 2012 03:31:17 +0000 Received: by yhmm54 with SMTP id m54so6038831yhm.19 for ; Mon, 16 Jul 2012 20:31:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=qfgeUkfxYqRke7pfSG9sBY7TzNjK2/SW7sMe4mng6uc=; b=FXPpvhI4JjatfLXfjRv0LYKFn1MN5Bwc5Jn7X2gyxwhF2RDLj6vA577xRkvxFnM1Gk P3vahYZ+J6XOwkUoLhwq6KCuT7b1VY0Y9bBGiazvq4M0Mbep7Z62Dk3yJRbfKm9a4Lmm EFK4/qbkqZ5tqaQY3txur5moHWaO31XZsDHAS87zs5888pkeTZCWSsrqkmF5XatQoH5S fdPxIcK3i1t6u5hDoqTNZQI0KCY86GqmCy5HcJ+JJ+D+C7/ITlcCK/LWCGVkQAdEhiQ4 oPKmT0LNufJA1pKfL3wOIPxfeB5GGM2CsQKIFgZHXFLuaKHGpngbM3pqy8OuoZltFVI8 qeCQ== Received: by 10.66.78.73 with SMTP id z9mr1964159paw.9.1342495862860; Mon, 16 Jul 2012 20:31:02 -0700 (PDT) Received: from ayaki.localdomain (office1.postnewspapers.com.au. [150.101.171.128]) by mx.google.com with ESMTPS id oo6sm13125424pbc.22.2012.07.16.20.31.00 (version=SSLv3 cipher=OTHER); Mon, 16 Jul 2012 20:31:02 -0700 (PDT) Message-ID: <5004DC70.7000808@ringerc.id.au> Date: Tue, 17 Jul 2012 11:30:56 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: Jon Nelson CC: pgsql-performance@postgresql.org Subject: Re: very very slow inserts into very large table References: <50041FD1.5070002@optrak.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQliXuh3lflXsRWHJrllHZtGaolZRB5yTze6zmCOArDdA1wvaHE/XGg39/XLQeFkAhD5YoS9 X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/202 X-Sequence-Number: 47383 On 07/17/2012 01:56 AM, Jon Nelson wrote: > What is the greater lesson to take away, here? If you are working with > data that is larger (substantially larger) than available memory, is > the architecture and design of postgresql such that the only real > approach is some type of data partitioning? It is not my intent to > insult or even disparage my favorite software, but it took less time > to *build* the indices for 550GB of data than it would have to insert > 1/20th as much. That doesn't seem right. To perform reasonably well, Pg would need to be able to defer index updates when bulk-loading data in a single statement (or even transaction), then apply them when the statement finished or transaction committed. Doing this at a transaction level would mean you'd need a way to mark indexes as 'lazily updated' and have Pg avoid using them once they'd been dirtied within a transaction. No such support currently exists, and it'd be non-trivial to implement, especially since people loading huge amounts of data often want to do it with multiple concurrent sessions. You'd need some kind of 'DISABLE INDEX' and 'ENABLE INDEX' commands plus a transactional backing table of pending index updates. Not simple. Right now, Pg is trying to keep the index consistent the whole time. That involves moving a heck of a lot of data around - repeatedly. Setting a lower FILLFACTOR on your indexes can give Pg some breathing room here, but only a limited amount, and at the cost of reduced scan efficiency. -- Craig Ringer