Queries
Why does count, min, max explain plan show a sort operation? SELECT count(1) FROM foo; SELECT min(x) FROM foo; Count/min/max/etc. will always show a sort operation in the explain plan because they are aggregate functions with an implicit group by even if they return only one row. They share the common code path even though it is effectively a no-op. Faster count avoiding full index/table scan with sampling: 1% sample SELECT COUNT(1) * 100 FROM SAMPLE (1); Find ALL FKs to a table: SELECT owner, constraint_name, constraint_type, table_name, r_owner, r_constraint_name FROM all_constraints WHERE constraint_type ='R' AND r_constraint_name IN (SELECT constraint_name FROM all_constraints WHERE constraint_type IN ('P','U') AND table_name ='DATA_AUDIT' );