Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 470017ACC82 for ; Wed, 8 Aug 2012 03:33:23 -0300 (ADT) Received: from mail-pb0-f46.google.com ([209.85.160.46]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SyzpZ-0007XK-G5 for pgsql-performance@postgresql.org; Wed, 08 Aug 2012 06:33:22 +0000 Received: by pbbrr13 with SMTP id rr13so959043pbb.19 for ; Tue, 07 Aug 2012 23:33:07 -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:x-gm-message-state; bh=MJWM4Nc0yBJwXZWxNL6QtvFqRySisZ6xVYZHK1cfzOI=; b=U76xD2huo3ymHUUTdLK0+aGTSNEHmbGH3HgYxf0dDj+JGSaNiHASnMDSOcurHESOun KzAGMX5/dVCBpA4uKVJAlK1BmBzlhMmGOLJp3JdQFKr/okEpHnN07W8u3N+dTKBGdPfa 55cSDmgbP9lmk1GjehYt117P587EgNFA1srxmIyq0nKshirOkaWQtqYsvbI2IZ8EVL/Y icrWC0ppqvAZtpAh94jxAG0OCVZ70ysNuNtyiW2N9MTyuLJFESss7eghTEeXUuA1n84p PieikiCa6XQ4alYUiPL9Z1kKdpfYFzE5I2veRcxpXMOiJyrQwZyntFCpHV0+L3NGQOEO Qklg== Received: by 10.68.224.70 with SMTP id ra6mr33499998pbc.11.1344407587750; Tue, 07 Aug 2012 23:33:07 -0700 (PDT) Received: from ayaki.localdomain (office1.postnewspapers.com.au. [150.101.171.128]) by mx.google.com with ESMTPS id or1sm7618462pbb.10.2012.08.07.23.33.05 (version=SSLv3 cipher=OTHER); Tue, 07 Aug 2012 23:33:06 -0700 (PDT) Message-ID: <5022081E.5080900@ringerc.id.au> Date: Wed, 08 Aug 2012 14:33:02 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: roberthanco@o2.pl CC: pgsql-performance@postgresql.org Subject: Re: Postgresql - performance of using array in big database References: <50220337.25b3650a.64b9.4287SMTPIN_ADDED@mx.google.com> In-Reply-To: <50220337.25b3650a.64b9.4287SMTPIN_ADDED@mx.google.com> Content-Type: multipart/alternative; boundary="------------010107040404060502010703" X-Gm-Message-State: ALoCoQlU5zjHWTNVpOD0mMdRo5W/dtzT18y6Fj9EWv3rw2/vVp1mqtVD2KKCiDezJfQ4Lvz6+q1X X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201208/57 X-Sequence-Number: 47595 This is a multi-part message in MIME format. --------------010107040404060502010703 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 08/03/2012 05:14 PM, roberthanco@o2.pl wrote: > It is read-only table so every integer column have an index. First tip: Define the table without the indexes. INSERT your data, and only after it is inserted create your indexes. Similarly, if you're making huge changes to the table you should consider dropping the indexes, making the changes, and re-creating the indexes. You might not have to drop the indexes if you aren't changing indexed fields, since HOT might save you, but it depends a lot on the specifics of the table's on-disk layout etc. > The server is: 12 GB RAM, 1,5 TB SATA, 4 CORES. All server for postgres. > There are many more tables in this database so RAM do not cover all > database. OK, in that case more info on the disk subsystem is generally helpful. Disk spin speed, type? RAID configuration if any? eg: 4 x 750GB 7200RPM Western Digital Black SATA 3 HDDs in RAID 10 using the Linux 'md' raid driver or 2 x 1.5TB 7200RPM "Enterprise/near-line" SATA3 HDDs in RAID 1 using a Dell PARC xxxx controller with BBU in write-back cache mode. ... though if you're only bulk-inserting the BBU doesn't matter much. > | > | I wonder what option would be better in performance point of view. I would advise you to test on a subset of your data. Try loading the same 50,000 records into different databases, one with each structure. Measure how long the load takes for each design, and how long the queries you need to run take to execute. Repeat the process with 500,000 records and see if one design slows down more than the other design does. Etc. > I need to make a good decision because import of this data will take > me a 20 days. For the sheer size of data you have you might want to think about using pg_bulkload. If you can't or don't want to do that, then at least use COPY to load big batches of your data. -- Craig Ringer --------------010107040404060502010703 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 08/03/2012 05:14 PM, roberthanco@o2.pl wrote:

> It is read-only table so every integer column have an index.

First tip: Define the table without the indexes. INSERT your data, and only after it is inserted create your indexes.

Similarly, if you're making huge changes to the table you should consider dropping the indexes, making the changes, and re-creating the indexes. You might not have to drop the indexes if you aren't changing indexed fields, since HOT might save you, but it depends a lot on the specifics of the table's on-disk layout etc.

The server is: 12 GB RAM, 1,5 TB SATA, 4 CORES. All server for postgres.
There are many more tables in this database so RAM do not cover all database.

OK, in that case more info on the disk subsystem is generally helpful. Disk spin speed, type? RAID configuration if any? eg:

  4 x 750GB 7200RPM Western Digital  Black SATA 3 HDDs in RAID 10 using the Linux 'md' raid driver

or

  2 x 1.5TB 7200RPM "Enterprise/near-line" SATA3 HDDs in RAID 1 using a Dell PARC xxxx controller with BBU in write-back cache mode.

... though if you're only bulk-inserting the BBU doesn't matter much.

I wonder what option would be better in performance point of view.

I would advise you to test on a subset of your data. Try loading the same 50,000 records into different databases, one with each structure. Measure how long the load takes for each design, and how long the queries you need to run take to execute. Repeat the process with 500,000 records and see if one design slows down more than the other design does. Etc.

I need to make a good decision because import of this data will take me a 20 days.

For the sheer size of data you have you might want to think about using pg_bulkload. If you can't or don't want to do that, then at least use COPY to load big batches of your data.

--
Craig Ringer
--------------010107040404060502010703--