Folgendes verwende ich derzeit: CREATE FUNCTION array_intersect(a1 anyarray, a2 anyarray) RETURNS anyarray AS $$ SELECT ARRAY( SELECT unnest($1) INTERSECT SELECT unnest($2) ORDER BY 1 ); $$ LANGUAGE sql IMMUTABLE STRICT; --get the length: select array_length ( array_intersect(array[...],...