Re: why we do not create indexes on master

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Valerii Valeev <valerii(dot)valeev(at)mail(dot)ru>
Cc: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: why we do not create indexes on master
Date: 2016-12-27 16:19:37
Message-ID: CAKFQuwbReSO7XxNm8rsi4PfWJ4h49qipiNbtQD_ntGYHw03Onw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Tue, Dec 27, 2016 at 8:22 AM, Valerii Valeev <valerii(dot)valeev(at)mail(dot)ru>
wrote:

> I have naive idea that it won’t help if index is created before the data
> is there — i.e. indexes on master aren’t updated when data loaded to child
> table.
>

​Indexes on the master table of a partition scheme never reflect the
contents of child​ tables.

In most partitioning schemes the master table is empty so even if it
doesn't have an index on a particular field execution would typically be
quick. This is why #4 on the page you linked to:

"""
For each partition, create an index on the key column(s), as well as any
other indexes you might want. (The key index is not strictly necessary, but
in most scenarios it is helpful. If you intend the key values to be unique
then you should always create a unique or primary-key constraint for each
partition.)
"""

doesn't say anything about creating other indexes on the master table. See
#1 in that list for an explicit statement of this assumption.

If the master is not empty, and of considerable size, and the field being
searched is not indexed, then it is unsurprising that the query would take
a long time to execute when obtaining rows from the master table. If this
is the case then you've gotten away from the expected usage of partitions
and so need to do things that aren't in the manual to make them work.

David J.

David J.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Valerii Valeev 2016-12-27 17:38:05 Re: why we do not create indexes on master
Previous Message Andreas Kretschmer 2016-12-27 16:04:27 Re: why we do not create indexes on master