X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4922C32A0C2 for ; Wed, 20 Oct 2004 02:53:40 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 29089-01 for ; Wed, 20 Oct 2004 01:53:35 +0000 (GMT) Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.202]) by svr1.postgresql.org (Postfix) with ESMTP id B540D329F75 for ; Wed, 20 Oct 2004 02:53:37 +0100 (BST) Received: by mproxy.gmail.com with SMTP id 73so414090rnk for ; Tue, 19 Oct 2004 18:53:38 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=T3K9MaxSDJgKoe2EwE8ohedc9NHCV9PzhjXVWD/ofRJY599qu8qPG3zqGIIyf68WcSE8HO3BDb5uUzutW/X5muz4pwQ9vzwCVsQzaJ5cT8BuLEpks0x9TdO0OAumJyBkXqqmHDlAcQtnPydKsB3zYtRKDvOhBDZwiEQTnFj38Uw Received: by 10.38.72.80 with SMTP id u80mr2280650rna; Tue, 19 Oct 2004 18:53:37 -0700 (PDT) Received: by 10.38.165.15 with HTTP; Tue, 19 Oct 2004 18:53:37 -0700 (PDT) Message-ID: <97b3fe2041019185337a8c3d8@mail.gmail.com> Date: Wed, 20 Oct 2004 11:53:37 +1000 From: Brock Henry Reply-To: Brock Henry To: pgsql-performance@postgresql.org Subject: Insert performance, what should I expect? Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/302 X-Sequence-Number: 8778 Hi,=20 I've after some opinions about insert performance. I'm importing a file with 13,002 lines to a database that ends up with 75,703 records across 6 tables. This is a partial file =E2=80=93 the real d= ata is 4 files with total lines 95174. I'll be loading these files each morning, and then running a number of queries on them. The select queries run fast enough, (mostly - 2 queries are slow but I'll look into that later), but importing is slower than I'd like it to be, but I'm wondering what to expect? I've done some manual benchmarking running my script 'time script.pl' I realise my script uses some of the time, bench marking shows that %50 of the time is spent in dbd:execute. Test 1, For each import, I'm dropping all indexes and pkeys/fkeys, then importing, then adding keys and indexes. Then I've got successive runs. I figure the reindexing will get more expensive as the database grows? Successive Imports: 44,49,50,57,55,61,72 (seconds) =3D average 1051inserts/second (which now that I've written this seems fairly good) Test 2, no dropping etc of indexes, just INSERTs Import =E2=80=93 61, 62, 73, 68, 78, 74 (seconds) =3D average 1091 inserts/second Machine is Linux 2.6.4, 1GB RAM, 3.something GHz XEON processor, SCSI hdd's (raid1). PostgreSQL 7.4.2. Lightly loaded machine, not doing much other than my script. Script and DB on same machine. Sysctl =E2=80=93a | grep shm kernel.shmmni =3D 4096 kernel.shmall =3D 134217728 (pages or bytes? Anyway=E2=80=A6) kernel.shmmax =3D 134217728 postgresql.conf tcpip_socket =3D true max_connections =3D 32 superuser_reserved_connections =3D 2 shared_buffers =3D 8192=20=20=20=20=20=20=20 sort_mem =3D 4096=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 vacuum_mem =3D 16384=20=20=20=20=20=20 max_fsm_relations =3D 300=20=20 fsync =3D true=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 wal_buffers =3D 64=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 checkpoint_segments =3D 10=20=20=20=20=20=20=20=20=20 effective_cache_size =3D 16000=20=20=20=20 syslog =3D 1=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20 silent_mode =3D false=20=20=20=20=20=20=20=20=20=20=20=20=20=20 log_connections =3D true log_pid =3D true log_timestamp =3D true stats_start_collector =3D true stats_row_level =3D true Can I expect it to go faster than this? I'll see where I can make my script itself go faster, but I don't think I'll be able to do much. I'll do some pre-prepare type stuff, but I don't expect significant gains, maybe 5-10%. I'd could happily turn off fsync for this job, but not for some other databases the server is hosting. Any comments/suggestions would be appreciated. Thanks :) Brock Henry