pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
To: pgsql-performance@postgresql.org
Subject: Re: SELECT INTO large FKyed table is slow
Date: Mon, 29 Nov 2010 20:11:39 +1300
Message-ID: <4CF3522B.2050203@catalyst.net.nz> (raw)
In-Reply-To: <4CF24103.8030209@megafon.hr>
References: <4CF24103.8030209@megafon.hr>

On 29/11/10 00:46, Mario Splivalo wrote:
>
> This is the slow part:
> INSERT INTO drones_history (sample_id, drone_id, drone_log_notice, 
> drone_temperature, drone_pressure)
> SELECT * FROM tmpUpdate;
>
> For 100 rows this takes around 2 seconds. For 1000 rows this takes 
> around 40 seconds. For 5000 rows this takes around 5 minutes.
> For 50k rows this takes around 30 minutes! Now this is where I start 
> lag because I get new CSV every 10 minutes or so.

Have you created indexes on drones_history(sample_id) and  
drones_history(drone_id)? That would probably help speed up your INSERT 
quite a bit if you have not done so.

Also it would be worthwhile for you to post the output of:

EXPLAIN ANALYZE INSERT INTO drones_history (sample_id, drone_id, 
drone_log_notice, drone_temperature, drone_pressure)
SELECT * FROM tmpUpdate;

to the list, so we can see what is taking the time.

Cheers

Mark



view thread (32+ messages)  latest in thread

Message-ID: <4CF3522B.2050203@catalyst.net.nz>
Permalink:  ../4CF3522B.2050203@catalyst.net.nz/
Also on:    postgresql.org/message-id/4CF3522B.2050203@catalyst.net.nz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: mark.kirkwood@catalyst.net.nz
  Subject: Re: SELECT INTO large FKyed table is slow
  In-Reply-To: <4CF3522B.2050203@catalyst.net.nz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox