I have a function that I think is defined as volatile, but I now know I want it stable.

How can I check the function volatility (volatile, stable, immutable) of a certain function?

When a function is defined as volatile, can I change the volatility to stable by using a create or replace function query? Or does the function needs to be dropped and created again but this time as stable?

create or replace function my_function()
returns int as $$
    select a
    from my_table
    order by 1
    limit 1
$$ language sql stable;

I checked the documentation for this, but it doesn't mention changing volatility.

1 Answer 1


I checked the documentation again, and the answer to my second question is, yes you can alter it using the alter function query.

alter function my_function() stable;

Also, I see that checking for function volatility has been asked and answered before.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.