character varying vs. text as function parameter types in PostgreSQL Is there any significant difference (in performance for example) between character varying vs. text as types for db function parameters? I have 2 usage examples:

Example 1:

CREATE OR REPLACE FUNCTION func1(table_name &lt;character varying|text&gt;)
  RETURNS integer AS $$
DECLARE
  RESULT integer;
BEGIN
  EXECUTE 'SELECT COUNT(*) FROM ' || table_name INTO result;
  RETURN result;
END; 
$$ LANGUAGE plpgsql;


Example 2:

CREATE OR REPLACE FUNCTION func2(filter_value &lt;character varying|text&gt;)
  RETURNS integer AS $$
DECLARE
  RESULT integer;
BEGIN
  SELECT COUNT(*) INTO RESULT FROM &lt;some_table&gt; WHERE &lt;some_column&gt; = filter_value;
  RETURN result;
END; 
$$ LANGUAGE plpgsql;


NOTE in the 2nd example the some_column type is text if filter_value is of type character varying and vice versa
When it comes to performance, these data types are exactly the same, down to the implementation in C.

If in doubt, use text, because that is the preferred type of its type class, and the data type resolution rules for functions will resolve all unknown strings to text implicitly. With character varying you often have to use explicit type casts.