Re: SELECT INTO large FKyed table is slow - Mailing list pgsql-performance

From Pierre C
Subject Re: SELECT INTO large FKyed table is slow
Date
Msg-id op.vmxyi50oeorkce@apollo13
Whole thread Raw
In response to Re: SELECT INTO large FKyed table is slow  (Mario Splivalo <mario.splivalo@megafon.hr>)
Responses Re: SELECT INTO large FKyed table is slow
Re: SELECT INTO large FKyed table is slow
List 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.

pgsql-performance by date:

Previous
From: "Pierre C"
Date:
Subject: Re: SELECT INTO large FKyed table is slow
Next
From: Robert Haas
Date:
Subject: Re: MVCC performance issue