Re: SELECT INTO large FKyed table is slow

From: Mark Kirkwood <mark(dot)kirkwood(at)catalyst(dot)net(dot)nz>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: SELECT INTO large FKyed table is slow
Date: 2010-11-30 23:50:29
Message-ID: 4CF58DC5.5040101@catalyst.net.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 30/11/10 05:53, Pierre C wrote:
>
>> 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.

Exactly, sorry - I was having a brain fade moment about which way your
foreign key checks were going when I suggested adding those indexes... :-(

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Mario Splivalo 2010-12-01 00:00:23 Re: SELECT INTO large FKyed table is slow
Previous Message Mario Splivalo 2010-11-30 23:24:32 Re: SELECT INTO large FKyed table is slow