Re: Improve perfomance for index search ANY(ARRAY[]) condition with single item

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dima Pavlov <imyfess(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Improve perfomance for index search ANY(ARRAY[]) condition with single item
Date: 2017-07-23 16:55:47
Message-ID: 12103.1500828947@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dima Pavlov <imyfess(at)gmail(dot)com> writes:
> The problem was discussed on stackoverflow:
> https://stackoverflow.com/questions/45061966/index-usage-with-single-item-anyarray

Usually, we're not very happy with submissions that reference external
pages for justification; we like to have all the relevant material in our
mail archives.

> That's my first patch so I will be grateful for constructive criticism.

I think it would be better to do this in the planner, see specifically
eval_const_expressions. That would allow the transformation to succeed
in more cases, like where the array is coming from a parameter rather
than an ARRAY[] construct. That is, you should be able to do this not
only for ARRAY[x] but for any single-element constant array.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-07-23 17:07:30 Re: Improve perfomance for index search ANY(ARRAY[]) condition with single item
Previous Message Tom Lane 2017-07-23 16:43:25 Re: Testlib.pm vs msys