Re: index scan over composite type
Teodor Sigaev <teodor@sigaev.ru>
From: Teodor Sigaev <teodor@sigaev.ru>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers <pgsql-hackers@postgreSQL.org>
Date: 2018-05-16T14:06:55Z
Lists: pgsql-hackers
Thank you. Seems, it works, at least I can't find a counter-example for that.
Tom Lane wrote:
> Teodor Sigaev <teodor@sigaev.ru> writes:
>> I'm not understand why postgres prefers to sort table instead of using
>> index only scan when query is a simple inner join on composite type.
>> Query with equality clause with constant works fine with index scan but
>> join not. Could somebody point me why? Thank you.
>
> Hmm ... the reason why not seems to be that canonicalize_ec_expression()
> improperly adds a RelabelType node, causing the composite-type Vars to not
> be recognized as matching the eclass they should match. The attached
> patch fixes it and doesn't seem to break anything in the regression tests.
>
> This raises the question of why we don't treat type RECORD more like a
> true polymorphic type, but that's a can of worms I don't particularly want
> to open right now. For the moment, this is the only IsPolymorphicType
> call in the planner AFAICS, so there's some reason to hope that we don't
> have more bugs of the same ilk.
>
> regards, tom lane
>
--
Teodor Sigaev E-mail: teodor@sigaev.ru
WWW: http://www.sigaev.ru/
Commits
-
Fix misprocessing of equivalence classes involving record_eq().
- a11b3bd37f14 11.0 landed
- bc711befd6ce 9.3.24 landed
- ace3c7cc0518 9.6.10 landed
- aada0a7648e2 10.5 landed
- 6d7629094a52 9.5.14 landed
- 62e0020ad491 9.4.19 landed