Re: SELECT INTO large FKyed table is slow

From: "Pierre C" <lists(at)peufeu(dot)com>
To: mark(dot)kirkwood(at)catalyst(dot)net(dot)nz, "Mario Splivalo" <mario(dot)splivalo(at)megafon(dot)hr>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: SELECT INTO large FKyed table is slow
Date: 2010-11-29 16:53:19
Message-ID: op.vmxyi50oeorkce@apollo13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance


> 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.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Robert Haas 2010-11-30 00:21:59 Re: MVCC performance issue
Previous Message Pierre C 2010-11-29 16:47:49 Re: SELECT INTO large FKyed table is slow