Jim, Thank you so much for spending time on this.
First thing I have noticed is that you might got the syntax wrong in your VALUES() version, the correct syntax needs _one_ VALUES at the beginning and then the actual values only.
I have tested your UNNEST variant too, it works equally fine. Best Martin On 09.05.2015 22:23, NSS Ltd wrote:
Martin, Testing, I see the syntax is more correctly : select mm.uid, mm.modseq, mm.message from mailbox_messages mm where mm.mailbox=441 and not mm.deleted and mm.uid=any(select * from unnest('{...}'::integer[])) I'm trying to find if this still uses the improved query plan. TIA Arnt, I see this issue has come up before in the source code - injector.cpp, line 768. The unnest or values variant may be a better solution than making the huge list of parameters. I'm trying some variations but don't have a 500,000 message mailbox to test with (over to Martin for that!). On 09/05/2015 17:37, NSS Ltd wrote:Martin, Can you please re-run the query but instead of using VALUES(x), can you alter the array to have an UNNEST clause : select mm.uid, mm.modseq, mm.message from mailbox_messages mm where mm.mailbox=441 and not mm.deleted and mm.uid=any(unnest('{...}')) Please tell me the performance/query plan on this compared with the original and with your VALUES() version. Thanks Jim
