I am new to postgresql (and SQL in general) and my biggest concern right now is optimization. Below I have a simple query. However I believe that it is just one query. However, it could also be the case that it is just 3 queries (the ones that exist new the union all). Or it might actually be 6 queries since there are actually 6 select statements.
with foo as (
select * from tableA
), bar as (
select * from tableB
), zeta as (
select * from tableC
)
select * from foo
union all
select * from bar
union all
select * from zeta
How many queries is the above query?
also...
The reason this question is important is because, I do not know whether I should write my query like the above or to simply just make all the queries separate.
select * from tableA; --query 1
select * from tableB; --query 2
select * from tableC; --query 3