Re: Performance decline maybe caused by multi-column index? - Mailing list pgsql-performance

From Jeff Janes
Subject Re: Performance decline maybe caused by multi-column index?
Date
Msg-id CAMkU=1xhc89G90gCYNxHO-hAoxzPZxE32NyJLwjQkJtbqR5Oyw@mail.gmail.com
Whole thread Raw
In response to Performance decline maybe caused by multi-column index?  (Jan Bauer Nielsen <jbn@dbc.dk>)
List pgsql-performance
On Fri, Mar 18, 2016 at 6:26 AM, Jan Bauer Nielsen <jbn@dbc.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


pgsql-performance by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: Disk Benchmarking Question
Next
From: Andreas Joseph Krogh
Date:
Subject: Re: Searching GIN-index (FTS) and sort by timestamp-column