Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 11E361337B5D for ; Mon, 25 Oct 2010 17:29:07 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 78832-02 for ; Mon, 25 Oct 2010 20:28:59 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-fx0-f46.google.com (mail-fx0-f46.google.com [209.85.161.46]) by mail.postgresql.org (Postfix) with ESMTP id 1F12F1337B4E for ; Mon, 25 Oct 2010 17:28:58 -0300 (ADT) Received: by fxm16 with SMTP id 16so3331416fxm.19 for ; Mon, 25 Oct 2010 13:28:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=jcrxlVF+gXISpuZomUrqk+/OSIdUZlA6DFRGiuiRjeY=; b=SJ7eUZrdvrkj12lyftUCH5Wp0yXL8AQmI5GEq+3FOySGgDsbuhn80z5Llz1GwazdJS xZNIYfNpPpCOnwOmCo2yYlYEAnZW6tfKanAkbiCIstaugCZaCZF0V5I4o2td5Grox+Ec xrpgG79xyJDzarLHh61shCs1/8e3kDlHuqyzo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=jwyhlzxdZL56ZH/KWzXxe3pGDi5RAzsVuMTmATjUs0t+XpUBvy6YBw/E2isbUl0Mlu ZHjlxHLsyabsBToPNMSAY+nKPXq9HjdTMELUpkfte2/fpAsCBCq4JsAHe+wKpIa3c7Gx 8If29poMZ8NZjLBkrJQsS7Rit93W0TgZWtEnM= MIME-Version: 1.0 Received: by 10.239.187.67 with SMTP id k3mr1035507hbh.157.1288038537858; Mon, 25 Oct 2010 13:28:57 -0700 (PDT) Received: by 10.239.133.143 with HTTP; Mon, 25 Oct 2010 13:28:57 -0700 (PDT) In-Reply-To: <402913.53404.qm@web65405.mail.ac4.yahoo.com> References: <402913.53404.qm@web65405.mail.ac4.yahoo.com> Date: Mon, 25 Oct 2010 16:28:57 -0400 Message-ID: Subject: Re: Postgres insert performance and storage requirement compared to Oracle From: Merlin Moncure To: Divakar Singh Cc: pgsql-performance@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201010/413 X-Sequence-Number: 40831 On Mon, Oct 25, 2010 at 2:12 PM, Divakar Singh wrote: > Hello Experts, > My application uses Oracle DB, and makes use of OCI interface. > I have been able to develop similar interface using postgreSQL library. > However, I have done some tests but results for PostgreSQL have not been > encouraging for a few of them. > > My questions/scenarios are: > > 1. How does PostgreSQL perform when inserting data into an indexed (type: > btree) table? Is it true that as you add the indexes on a table, the > performance deteriorates significantly whereas Oracle does not show that > much performance decrease. I have tried almost all postgreSQL performance > tips available. I want to have very good "insert" performance (with > indexes), "select" performance is not that important at this point of time. > > 2. What are the average storage requirements of postgres compared to Oracle? > I inserted upto 1 million records. The storage requirement of postgreSQL is > almost double than that of Oracle. >u > Thanks in anticipation. I ran the following tests w/libpqtypes. While you probably wont end up using libpqtypes, it's illustrative to mention it because it's generally the easiest way to get data into postgres and by far the fastest (excluding 'COPY'). source code follows after the sig (I banged it out quite quickly, it's messy!) :-). I am not seeing your results. via libpqtypes: Inserting, begin..insert..(repeat 1000000x) commit; local workstation: 2m24s remote server: 8m8s via libpqtypes, but stacking array and unstacking on server (this could be optimized further by using local prepare): local workstation: 43s (io bound) remote server: 29s (first million) remote server: 29s (second million) create index (1.8s) remote remote server: 33s (third million, w/index) obviously insert at a time tests are network bound. throw a couple of indexes in there and you should see some degradation, but nothing too terrible. merlin libpqtypes.esilo.com ins1.c (insert at a time) #include "libpq-fe.h" #include "libpqtypes.h" #define INS_COUNT 1000000 int main() { int i; PGconn *conn = PQconnectdb("host=devdb dbname=postgres port=8071"); if(PQstatus(conn) != CONNECTION_OK) { printf("bad connection"); return -1; } PQtypesRegister(conn); PQexec(conn, "begin"); for(i=0; i