Run multiple queries with a single HTTP request #900
-
Is it currently possible to run multiple SQL queries with a single HTTP request with Supabase? For instance, if you have a dashboard overview page, it's totally possible to need to query multiple tables independently to provide a wholistic overview of someone's data. And with queries that, to my knowledge, aren't idiomatic to SQL's table joins. For instance, the best way I know to query multiple tables simultaneously is: const [response1, response2, response3] = await Promise.all([
supabase.from('table1').select('*'),
supabase.from('table2').select('*'),
supabase.from('table3').select('*'),
]) But, I believe that results in 3 HTTP requests. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I see two options here:
-- sample dynamic table function
create function all_data(user_id uuid)
returns table(table1_col int, table2_col text, table3_col text) -- can have different types of columns coming from different tables
as $$
-- here you can use CTEs, FOR LOOPS, variables, etc
return ...;
$$ language plpgsql; Both would be done in one http request. |
Beta Was this translation helpful? Give feedback.
I see two options here: