Skip to content

Instantly share code, notes, and snippets.

@warpgate3
Created November 29, 2018 06:51
Show Gist options
  • Select an option

  • Save warpgate3/c1309f54e0564827f44d07bace610f15 to your computer and use it in GitHub Desktop.

Select an option

Save warpgate3/c1309f54e0564827f44d07bace610f15 to your computer and use it in GitHub Desktop.
functional index to_char on the postgresql (to_char, immutable issue)
CREATE OR REPLACE FUNCTION my_to_char(some_time timestamp)
RETURNS text
AS
$BODY$
select to_char($1, 'yyyy-mm-dd');
$BODY$
LANGUAGE sql
IMMUTABLE;
CREATE INDEX fc_op_vist_idx_function_med_dt ON table (my_to_char(MED_DT, 'YYYY-MM'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment