From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: How to use the BRIN index properly?
Date: Wed, 8 Feb 2023 16:20:18 -0600
Message-ID: <7f0732ff-c739-3d42-a8e7-d9779f415f94@gmail.com> (raw)
In-Reply-To: <CAPqV3pQRP_wWYmXO0sYpO+ohj7yiSZzmVSwmcB-Lz2NPgwO_cg@mail.gmail.com>
References: <CAPqV3pRdiDEiNiHmH82N-eWPVsKKHQ=EUn0e7Zu0+EJCW7GbQA@mail.gmail.com>
<CAPqV3pQCPas3CzMx-Syed_-Kzn_Vsq=b=H=_SgoXbFW58-mmWA@mail.gmail.com>
<d0043a0b-29a1-8c83-6ea9-af0b2f1d6a25@gmail.com>
<CAPqV3pRaEPb5Lj3mGuFCcJARbS90ZX0EfX36zw5N9jw9vigwnA@mail.gmail.com>
<4CCC40F6-D1FF-4446-B50C-26A8843E6EE4@thebuild.com>
<CAPqV3pQRP_wWYmXO0sYpO+ohj7yiSZzmVSwmcB-Lz2NPgwO_cg@mail.gmail.com>
1. The whole index does not need to fit in memory, just the parts of it you
need at that time.
2. Partition the table by the primary key. Each index will be *much*
smaller, since each child will be smaller.
On 2/8/23 16:14, Siddharth Jain wrote:
> OK so in that case we are left with the B-Tree index.
>
> If the B-Tree index will be so large that it cannot fit in memory, then is
> it worth creating it at all? Are there any established patterns here?
>
> On Wed, Feb 8, 2023 at 1:21 PM Christophe Pettus <xof@thebuild.com> wrote:
>
>
>
> > On Feb 8, 2023, at 13:17, Siddharth Jain <siddhsql@gmail.com> wrote:
> >
> > As I explained in my question that is indeed our dilemma. Our
> insertion order will not be equal to index order. i.e., referring to
> your response:
> >
> > > who's data is added in the same order as the key in the BRIN index
> >
> > does NOT hold.
>
> A BRIN index is not a good choice in this case. You can CLUSTER the
> data on an index, but that's a one-time operation: PostgreSQL will not
> maintain that order after the CLUSTER. If the number of rows in the
> table at the time of the CLUSTER is much larger than the number that
> are inserted between CLUSTER operations, then a BRIN index might be
> useful, but clustering a very large table is an expensive operation,
> and requires an exclusive lock on the table while it is being done.
>
--
Born in Arizona, moved to Babylonia.
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: ronljohnsonjr@gmail.com
Subject: Re: How to use the BRIN index properly?
In-Reply-To: <7f0732ff-c739-3d42-a8e7-d9779f415f94@gmail.com>
References: <CAPqV3pRdiDEiNiHmH82N-eWPVsKKHQ=EUn0e7Zu0+EJCW7GbQA@mail.gmail.com> <CAPqV3pQCPas3CzMx-Syed_-Kzn_Vsq=b=H=_SgoXbFW58-mmWA@mail.gmail.com> <d0043a0b-29a1-8c83-6ea9-af0b2f1d6a25@gmail.com> <CAPqV3pRaEPb5Lj3mGuFCcJARbS90ZX0EfX36zw5N9jw9vigwnA@mail.gmail.com> <4CCC40F6-D1FF-4446-B50C-26A8843E6EE4@thebuild.com> <CAPqV3pQRP_wWYmXO0sYpO+ohj7yiSZzmVSwmcB-Lz2NPgwO_cg@mail.gmail.com> <7f0732ff-c739-3d42-a8e7-d9779f415f94@gmail.com>
* 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