pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Pierre C <lists@peufeu.com>
To: mark.kirkwood@catalyst.net.nz, "Mario Splivalo" <mario.splivalo@megafon.hr>
Cc: pgsql-performance@postgresql.org
Subject: Re: SELECT INTO large FKyed table is slow
Date: Mon, 29 Nov 2010 17:53:19 +0100
Message-ID: <op.vmxyi50oeorkce@apollo13> (raw)
In-Reply-To: <4CF39CF4.2050506@megafon.hr>
References: <4CF24103.8030209@megafon.hr>
	<4CF3522B.2050203@catalyst.net.nz>
	<4CF39CF4.2050506@megafon.hr>


> Yes, since (sample_id, drone_id) is primary key, postgres created  
> composite index on those columns. Are you suggesting I add two more  
> indexes, one for drone_id and one for sample_id?

(sample_id,drone_id) covers sample_id but if you make searches on drone_id  
alone it is likely to be very slow since you got a large number of  
sample_ids. Postgres can use any column of a multicolumn index but it is  
only interesting performance-wise if the cardinality of the first  
(ignored) columns is low. If you often make searches on drone_id, create  
an index. But this isn't what is slowing your foreign key checks.

>> 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.
>
> Is there a way to do so inside plpgsql function?
>
> I can recreate the whole process within psql and then post the explain  
> analyze, it would just take me some time to do so. I'll post as soon as  
> I'm done.

Yes, this would be interesting.



view thread (32+ messages)  latest in thread

Message-ID: <op.vmxyi50oeorkce@apollo13>
Permalink:  ../op.vmxyi50oeorkce@apollo13/
Also on:    postgresql.org/message-id/op.vmxyi50oeorkce@apollo13

 · 

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: lists@peufeu.com, mario.splivalo@megafon.hr
  Subject: Re: SELECT INTO large FKyed table is slow
  In-Reply-To: <op.vmxyi50oeorkce@apollo13>

* 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