Is it possible to translate PostgREST queries to SQL inside of Postgres? #3817
-
Does postgREST expose a SQL function that would allow you to translate a PostgREST query to a SQL query? Basically, perform this part of the execution pipeline: _Reference from Architecture docs_ Or the opposite, the supabase SQL -> Rest API translator (but executed from SQL). SELECT * FROM translatePostgREST(
'books?select=title,description&description=ilike.*cheese*&order=title.desc&limit=5&offset=10'
)
-- would produce:
select
title,
description
from
books
where
description ilike '%cheese%'
order by
title desc
limit
5
offset
10 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
No, this translation is done via Haskell, not SQL, so we don't have a function to expose. You could enable statement logging to see which queries PostgREST is running: https://docs.postgrest.org/en/v12/references/observability.html#database-logs If you just want to see execution plans, you can do it like this: https://docs.postgrest.org/en/v12/references/observability.html#execution-plan |
Beta Was this translation helpful? Give feedback.
No, this translation is done via Haskell, not SQL, so we don't have a function to expose.
You could enable statement logging to see which queries PostgREST is running: https://docs.postgrest.org/en/v12/references/observability.html#database-logs
If you just want to see execution plans, you can do it like this: https://docs.postgrest.org/en/v12/references/observability.html#execution-plan