How to shrink a large query - Postgresql [closed]

0

In Visual Studio, we have the possibility to shrink a large code, that is, visually decrease the size, as a way to make reading easier, for example:

#region

Seu código aqui...

#endregion

I would like to do the same in a query within my PGAdmin. Is it possible?

    
asked by anonymous 21.05.2018 / 18:24

1 answer

1

Man, unfortunately not. The querys often have hundreds or even thousands of rows, it will depend on the size of the database. They are really great files. In Postgres you can better organize the querys using one or several CTE's (Common Table Expression)

WITH cte AS (
         SELECT 
           tabela1.coluna1, 
           tabela1.coluna2, 
           tabela1.coluna3 
         FROM 
           schema1.tabela1
)
SELECT * FROM cte

The CTE is a temporary table that only exists during the execution of the query.

Reducing the size itself is impossible, but to "break" into smaller pieces to aid in both reading and execution.

    
25.05.2018 / 20:01