Thursday, July 26, 2018

Re: Optimizing Prefetch for Postgres IN Limit

> On Jul 25, 2018, at 02:59, Jason <jjohns98684@gmail.com> wrote:
>
> Where do you get that in the pg documentation? I can't find that anywhere (google-fu may be failing me), and we do have some queries with more than 100 values using IN.

It's slightly more complicated than that. Above 100 entries, the PostgreSQL optimizer won't try to do optimizations of the form changing i IN (1, 2 ..., 101) to (i = 1) OR (i = 2) OR (i = 3)... to see if there's a better way of executing the query. It *can* still do an index scan in those cases, although the more entries in the IN list, the less efficient that will be. In general, large IN clauses aren't a great idea; they're better replaced with a join.

--
-- Christophe Pettus
xof@thebuild.com

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8A21227D-94A9-459F-89D0-771D3052C0C0%40thebuild.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment