Project

General

Profile

« Previous | Next » 

Revision 8326

schemas/util.sql: mk_subset_by_row_num_func(): Also create subset function which turns off enable_sort. This is used for limit values greater than ~100,000 to avoid unwanted slow sorts. The regular subset function is still needed to work with EXPLAIN, so that it produces expanded output instead of just a function scan.

View differences:

schemas/util.sql
854 854
  COST 100
855 855
  ROWS 1000
856 856
$$;
857
-- Also create subset function which turns off enable_sort
858
	EXECUTE $$
859
CREATE OR REPLACE FUNCTION $$||view_||$$(no_sort boolean, limit_ integer DEFAULT NULL::integer, offset_ integer DEFAULT NULL)
860
  RETURNS SETOF $$||view_||$$
861
  SET enable_sort TO 'off'
862
  AS
863
$BODY1$
864
SELECT * FROM $$||util.type_qual_name(view_::text::regtype)||$$($1, $2)
865
$BODY1$
866
  LANGUAGE sql STABLE
867
  COST 100
868
  ROWS 1000
869
;
870
COMMENT ON FUNCTION $$||view_||$$(no_sort boolean, limit_ integer, offset_ integer) IS '
871
Use this for limit values greater than ~100,000 to avoid unwanted slow sorts.
872
If you want to run EXPLAIN and get expanded output, use the regular subset
873
function instead. (When a config param is set on a function, EXPLAIN produces
874
just a function scan.)
875
';
876
$$;
857 877
END;
858 878
$_$;
859 879

  

Also available in: Unified diff