Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ahOkw-0007ii-KD for pgsql-performance@arkaria.postgresql.org; Sat, 19 Mar 2016 21:49:58 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1ahOkv-0007I2-DF for pgsql-performance@arkaria.postgresql.org; Sat, 19 Mar 2016 21:49:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ahOjG-0005PE-38 for pgsql-performance@postgresql.org; Sat, 19 Mar 2016 21:48:14 +0000 Received: from mail-lb0-x22f.google.com ([2a00:1450:4010:c04::22f]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1ahOjD-000174-7i for pgsql-performance@postgresql.org; Sat, 19 Mar 2016 21:48:13 +0000 Received: by mail-lb0-x22f.google.com with SMTP id qe11so53058159lbc.3 for ; Sat, 19 Mar 2016 14:48:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=GCvs2Wjx5D1Ou1kndfRUwOXVuEju8MMVBOTU2GV2UDA=; b=JNJuB00U8zlwSL1KSiwYyVGC9vGW5UIYjx9LM+L6ewxORs3Q21mw72gbHQXCE0eHB+ JYD/J9VApbsemYjl2kbLwNNOxBbbEPXEWTijly2zEPs4DuGZ050enM7dqDNQUlkTY/v0 T754zgFQGML+3SFJbk8utXgzsLZ8dJxl4eKw0jAOCHeI7dqMX63gSK/erpNmNwd+7Q2A vc6xisfpXwnrGEl7OLCyt9SAO1TVB4os+hzb7JMSBDjgA0YP/CW27JrZtfDpZI/I3sRW QXmsgxkmjvWBRQD9f6MmJp94pkTNK5mPUxM3ocWyvwwl6EV4TVNIPKMhkskChcUo5lKz nA5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=GCvs2Wjx5D1Ou1kndfRUwOXVuEju8MMVBOTU2GV2UDA=; b=HSBTyu23DP7tE3DGEkAunvqoXMXPXjJZhmpwzB/4SIl1e/85NqkWqunMCEjUqH4Eee XMhmRyI9gXfWD5sbcg+98FOB0uzrEXIVDybq5PeV6kakbA/oxeg46Exmfb8FPPbEgBuR 0NWv31TLg3oZmopXboxVRvl6EHpT86wwKayHYYKjtjxWVG8gLI/qF3asZOO3B0dbPaRH tSxU1NwrTgJSd7rid0456J0M7RoKrVfCd1tS6C+yU1HIa02L14bHnBSNuN9rq0y818lA HKGk0iCFE3P8TieAbRNbmSqz14wiD/QPyVwYoxH51VSAYgvD3DeFvvvfzxf4w3oHUZL3 7Xmg== X-Gm-Message-State: AD7BkJI9xrGKjEo2aRbsV2LoBBG3Z9uzftjzq4YhClws04M5YtjZ+VT5AdPAsNtaYEIKsdHv3aCsJ8OeiWnSXg== MIME-Version: 1.0 X-Received: by 10.112.157.105 with SMTP id wl9mr8279067lbb.137.1458424088149; Sat, 19 Mar 2016 14:48:08 -0700 (PDT) Received: by 10.25.145.14 with HTTP; Sat, 19 Mar 2016 14:48:08 -0700 (PDT) In-Reply-To: <56EC01F6.9090400@dbc.dk> References: <56EC01F6.9090400@dbc.dk> Date: Sat, 19 Mar 2016 14:48:08 -0700 Message-ID: Subject: Re: Performance decline maybe caused by multi-column index? From: Jeff Janes To: Jan Bauer Nielsen Cc: "pgsql-performance@postgresql.org" Content-Type: text/plain; charset=UTF-8 X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On Fri, Mar 18, 2016 at 6:26 AM, Jan Bauer Nielsen wrote: > Hi, > > While developing a batch processing platform using postgresql as the > underlying data store we are seeing a performance decline in our > application. > > In this application a job is broken up into chunks where each chunk contains > a number of items (typically 10). > > CREATE TABLE item ( > id SMALLINT NOT NULL, > chunkId INTEGER NOT NULL, > jobId INTEGER NOT NULL, > -- other attributes omitted for brewity > PRIMARY KEY (jobId, chunkId, id) > ); > > So a job with 600.000 items results in 600.000 rows in the items table with > a fixed jobId, chunkId ranging from 0-59999 and for each chunkId an id > ranging from 0-9. Is it 0-59999 in order, or in some arbitrary order? > > All ten inserts for a particular chunkId are handled in a single > transaction, and over time we are seeing an increase in transaction > execution time, <100ms for the first 100.000 items, >300ms when we reach the > 400.000 mark, and the trend seems to be forever increasing. Why such small transactions? Why not do the entire 600.000 in on transaction? Are you inserting them via COPY, or doing single-valued inserts in a loop, or inserts with multiple value lists? > > No decline is observed if we instead sequentially submit 6 jobs of 100.000 > items each. > > Therefore we are beginning to wonder if we are hitting some sort of upper > limit with regards to the multi column index? Perhaps something causing it > to sort on disk or something like that? My gut feeling is that is more about memory management in your client, rather than something going on in the database. What does `top`, or `perf top`, show you about what is going on? Can you produce a simple perl or python script that reproduces the problem? Cheers, Jeff -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance