pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: amborodin@acm.org
Cc: Andrew Borodin <borodin@octonica.com>
Cc: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: Amit Kapila <amit.kapila16@gmail.com>
Cc: Alexander Korotkov <a.korotkov@postgrespro.ru>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Cc: Oleg Bartunov <obartunov@gmail.com>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Sergey Mirvoda <sergey@mirvoda.com>
Subject: Re: Re: GiST optimizing memmoves in gistplacetopage for fixed-size updates [PoC]
Date: Thu, 8 Sep 2016 18:23:00 -0300
Message-ID: <20160908212300.GA61876@alvherre.pgsql> (raw)
In-Reply-To: <5108.1473368916@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Tom Lane wrote:
> Hey Alvaro, can you comment on this bit in the proposed patch?
> 
> +		for (i = FirstOffsetNumber; i <= itemcount; i++)
> +		{
> +			ItemId		ii = PageGetItemId(phdr, i);
> +
> +			/* Normally here was following assertion
> +			 * Assert(ItemIdHasStorage(ii));
> +			 * This assertion was introduced in PageIndexTupleDelete
> +			 * But if this function will be used from BRIN index
> +			 * this assertion will fail. Thus, here we do not check that
> +			 * item has the storage.
> +			 */
> +			if (ItemIdGetOffset(ii) <= offset)
> +				ii->lp_off += size_diff;
> +		}
> +	}
> 
> That comment seems utterly wrong to me, because both PageIndexTupleDelete
> and PageIndexMultiDelete certainly contain assertions that every item on
> the page has storage.  Are you expecting that any BRIN index items
> wouldn't?  If they wouldn't, is adjusting their lp_off as if they did
> have storage sensible?

It is possible in BRIN to have empty intermediate tuples; for example it
is possible for lp 1 and 3 to contain index tuples, while lp 2 does not.

This is a tricky case to reproduce, but I think this should do it:
consider a table with pages_per_range=1.  Page 1 is summarized by index
tuple 1, page 2 is summarized by itup 2, page 3 is summarized by index
tuple 3.  On heap page 2 a new tuple is inserted and the summary data is
now much larger, such that the summary tuple no longer fits in the index
page, so it is moved to a new index page.  Then index tuple 2 in the
first index page becomes unused.  Revmap still points to lp 3, so it
can't be moved to lp 2.  The lp_offs can be adjusted, as long as the lp
itself is not moved from its original position.

Now if this loop is concerned only with live lps and does not move lps,
then it should be fine to add the assertion.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (36+ messages)  latest in thread

Message-ID: <20160908212300.GA61876@alvherre.pgsql>
Permalink:  ../20160908212300.GA61876@alvherre.pgsql/
Also on:    postgresql.org/message-id/20160908212300.GA61876@alvherre.pgsql

 · 

reply

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-hackers@postgresql.org
  Cc: alvherre@2ndquadrant.com, tgl@sss.pgh.pa.us, amborodin@acm.org, borodin@octonica.com, a.lubennikova@postgrespro.ru, michael.paquier@gmail.com, amit.kapila16@gmail.com, a.korotkov@postgrespro.ru, obartunov@gmail.com, hlinnaka@iki.fi, sergey@mirvoda.com
  Subject: Re: GiST optimizing memmoves in gistplacetopage for fixed-size updates [PoC]
  In-Reply-To: <20160908212300.GA61876@alvherre.pgsql>
  References: <5108.1473368916@sss.pgh.pa.us> <20160908212300.GA61876@alvherre.pgsql>

* 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