Re: COPY and indices? - Mailing list pgsql-general

From Ondrej Ivanič
Subject Re: COPY and indices?
Date
Msg-id CAM6mieJwNOMXnnLkBRpwn8X2R9n=f8Du7Kb8r-J7MpH5ZbS2Bw@mail.gmail.com
Whole thread Raw
In response to COPY and indices?  (François Beausoleil <francois@teksol.info>)
List pgsql-general
Hi,

On 13 March 2012 15:11, François Beausoleil <francois@teksol.info> wrote:
> When using COPY FROM STDIN to stream thousands of rows (20k and more hourly), what happens with indices? Are they
updatedonly once after the operation, or are they updated once per row? Note that I'm not replacing the table's data:
I'mappending to what's already there. I suspect batching writes will be faster than writing each individual row using
anINSERT statement. 

Yes, it will be faster to use COPY than plain INSERTs. We have similar
situation -- up to 10k rows every 3 minutes and around 15 indexes on
the table. Table is portioned and we do not update data. Check bloat
query reports some bloat but it growing very slowly and there is new
partition every month.

>
> Currently, I can sustain 30-40 writes per second on a Rackspace VPS. I know it's not the ideal solution, but that's
whatI'm working with. Following vmstat, the server is spending 30 to 40% of it's time in iowait. I don't have
measurementsas to what files are touched, and I'd welcome suggestions to measure the time PostgreSQL actually spends
writingindices vs data. 

Drop all indexes, measure time to insert and collect iostat output.
Create indexes, repeat the process and compare the results

--
Ondrej Ivanic
(ondrej.ivanic@gmail.com)

pgsql-general by date:

Previous
From: François Beausoleil
Date:
Subject: COPY and indices?
Next
From: Scott Marlowe
Date:
Subject: Re: COPY and indices?