Skip to content

Performance difference between postgREST filtering and native WHERE clause #3755

Discussion options

You must be logged in to vote

Is this difference in performance expected?

Yes, because the arguments are applied on the query inside the function, while the non-argument filters are applied on the result outside of the function. Since your function is a plpgsql, volatile function it is not inline-able and PostgreSQL can't push your conditions into the inner query. Thus the query inside the function runs to completion and is filtered afterwards.

It seems your function can be marked STABLE. Also replace it with a pure SQL function instead of plpgsql. This should give you a chance of inlining the function call - you can then see whether the =eq. style request performs better. If it doesn't, make sure to look at the exp…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@BorislavZlatanov
Comment options

@steve-chavez
Comment options

@wolfgangwalther
Comment options

Answer selected by BorislavZlatanov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants