Fastest query for selecting arrays that contain duplicates
Among the fastest ways to run such a query is with a specialized index:

create index on user_info ((anyarray_uniq(phones) &lt;&gt; phones)) where
    anyarray_uniq(phones) &lt;&gt; phones;


That way the work of doing the comparisons happens when the records are inserted or updated, not when they are selected.  (To get this to work, you will have to mark as anyarray_uniq as IMMUTABLE, but as far as I can tell this is an accurate way to mark it)