Re: Performance decline maybe caused by multi-column index?

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Jan Bauer Nielsen <jbn(at)dbc(dot)dk>
Cc: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Performance decline maybe caused by multi-column index?
Date: 2016-03-19 21:48:08
Message-ID: CAMkU=1xhc89G90gCYNxHO-hAoxzPZxE32NyJLwjQkJtbqR5Oyw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Fri, Mar 18, 2016 at 6:26 AM, Jan Bauer Nielsen <jbn(at)dbc(dot)dk> 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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Vick Khera 2016-03-21 14:15:12 Re: grant select on pg_stat_activity
Previous Message Scott Marlowe 2016-03-19 10:32:13 Re: Disk Benchmarking Question