How to shrink a large query - Postgresql

Asked

Viewed 45 times

0

In Visual Studio, we have the possibility to shrink a large code, IE, visually decrease the size, as a way to facilitate reading, example:

#region

Seu código aqui...

#endregion

I would like to do the same in a query within my Pgadmin. It is possible?

1 answer

1

Dude, unfortunately not. Querys often have hundreds or even thousands of lines, it will depend on the size of the database. These are really big 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

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.