Re: Composite Datums containing toasted fields are a bad idea(?)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Noah Misch <noah(at)leadboat(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Composite Datums containing toasted fields are a bad idea(?)
Date: 2014-04-27 22:44:16
Message-ID: 28295.1398638656@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
>> Just for some clarity, that also happens with expressions like:
>> WHERE
>> ROW(ev_class, rulename, ev_action) >= ROW('pg_rewrite'::regclass, '_RETURN', NULL)
>> ORDER BY ROW(ev_class, rulename, ev_action);

> Previously we wouldn't detoast ev_action here, but now we do.

No, we don't; not in that WHERE expression, because it's a RowCompareExpr
which does not involve forming any composite datums. We'd only detoast if
the row comparison actually gets to that column --- which is the same
behavior as before.

The extra detoast you're seeing in this example is caused by the ROW()
in the ORDER BY. Which, as I said, is just bad SQL coding.

> I agree that this needs to get backpatched at some point. But people
> also get very upset if queries gets slower by a magnitude or two after a
> minor version upgrade. And this does have the potential to do that, no?

They don't get nearly as upset as they do if the database loses their
data. Yes, in an ideal world, we could fix this and not suffer any
performance loss anywhere. But no such option is on the table, and
waiting is not going to make one appear. What waiting *will* do is
afford more opportunities for this bug to eat people's data.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-04-28 01:24:44 pgsql: Can't completely get rid of #ifndef FRONTEND in palloc.h :-(
Previous Message Andres Freund 2014-04-27 22:10:43 Re: Composite Datums containing toasted fields are a bad idea(?)