Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f4R4j-0001Be-5z for pgsql-general@arkaria.postgresql.org; Fri, 06 Apr 2018 13:06:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f4R4h-0001HK-WE for pgsql-general@arkaria.postgresql.org; Fri, 06 Apr 2018 13:06:39 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f4R4h-0001HB-Kb for pgsql-general@lists.postgresql.org; Fri, 06 Apr 2018 13:06:39 +0000 Received: from server5.simfrete.com ([177.52.183.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f4R4b-0004WL-ON for pgsql-general@lists.postgresql.org; Fri, 06 Apr 2018 13:06:37 +0000 Received: from [192.168.10.30] (unknown [177.52.183.17]) by server5.simfrete.com (Postfix) with ESMTPSA id E2DF5240442 for ; Fri, 6 Apr 2018 10:10:09 -0300 (-03) Subject: Re: decompose big queries To: pgsql-general@lists.postgresql.org References: From: Edson Carlos Ericksson Richter Message-ID: <40cd1824-1dd0-1aad-2c8d-c34ee510b5c5@simkorp.com.br> Date: Fri, 6 Apr 2018 10:06:28 -0300 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: pt-BR List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Em 05/04/2018 19:39, hmidi slim escreveu: > Hi, > I want to know what are the best practice to use in order to decompose > a big query which contains so many joins.Is it recommended to use > stored procedures ? or is there any other solution? > I don't know if there are best practices (each scenario requires its own solution), but for plain complex SELECT queries, I do use "WITH" queries... They work really well. https://www.postgresql.org/docs/9.6/static/queries-with.html Regards, Edson