From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Damir Ciganović-Janković <damir.ciganovic.jankovic@gmail.com>
Cc: Langote_Amit_f8@lab.ntt.co.jp
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15334: Partition elimination not working as expected when using enum as partition key
Date: Fri, 17 Aug 2018 12:21:30 +0100
Message-ID: <87r2ix2qm1.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <CA+-2sJ5m0QHQcBDXiNduUmHDv-fkzAR61LJg2W+_dUo9bUortw@mail.gmail.com>
References: <153442831773.1504.1930023229211807055@wrigleys.postgresql.org>
<1fff2a8b-92ef-c9e0-6a57-0e887d95c62b@lab.ntt.co.jp>
<CA+-2sJ6dZaZRnnHfKPRAqnyYF+9Pz4EtDnwNsSJ45jc10hmsgw@mail.gmail.com>
<dfd66017-7189-ad6b-1c5f-88e37f23ff56@lab.ntt.co.jp>
<CA+-2sJ5m0QHQcBDXiNduUmHDv-fkzAR61LJg2W+_dUo9bUortw@mail.gmail.com>
>>>>> "Damir" == Damir Ciganović-Janković <damir.ciganovic.jankovic@gmail.com> writes:
>> It's the Postgres EXPLAIN's code for expression deparsing that puts
>> the '::cstring' there. I have to wonder why it couldn't just skip
>> adding that and print it as simply 'A'::ab. However, I'm not sure if
>> answer to that question is related to why partition pruning doesn't
>> occur.
I think what's happening there is this: the parameter value needs a cast
from text to "ab"; this cast is an IO cast, so it becomes
enum_in(textout('A'),oid), and simplify_function can process
textout('A') as a constant (since textout is immutable) but not
enum_in('A',oid) (because enum_in is only stable, since it depends on
the enum label definitions). So the simplified expression becomes
('A'::cstring)::ab even though that's not actually a valid cast in
normal circumstances.
I haven't checked the partition code, but my guess is that since that's
not a constant (due to the stable cast), it can't be used for pruning in
pg10 (in pg11 it seems to get pruned at execution time).
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-bugs@postgresql.org
Cc: andrew@tao11.riddles.org.uk, damir.ciganovic.jankovic@gmail.com, Langote_Amit_f8@lab.ntt.co.jp
Subject: Re: BUG #15334: Partition elimination not working as expected when using enum as partition key
In-Reply-To: <87r2ix2qm1.fsf@news-spur.riddles.org.uk>
References: <153442831773.1504.1930023229211807055@wrigleys.postgresql.org> <1fff2a8b-92ef-c9e0-6a57-0e887d95c62b@lab.ntt.co.jp> <CA+-2sJ6dZaZRnnHfKPRAqnyYF+9Pz4EtDnwNsSJ45jc10hmsgw@mail.gmail.com> <dfd66017-7189-ad6b-1c5f-88e37f23ff56@lab.ntt.co.jp> <CA+-2sJ5m0QHQcBDXiNduUmHDv-fkzAR61LJg2W+_dUo9bUortw@mail.gmail.com> <87r2ix2qm1.fsf@news-spur.riddles.org.uk>
* 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