Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1legat-0002FR-4m for pgsql-performance@arkaria.postgresql.org; Thu, 06 May 2021 16:11:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1legar-0007B3-Om for pgsql-performance@arkaria.postgresql.org; Thu, 06 May 2021 16:11:17 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1legar-0007Av-Gc for pgsql-performance@lists.postgresql.org; Thu, 06 May 2021 16:11:17 +0000 Received: from mxh02aws90.mxout.inova.com.br ([3.219.79.34] helo=mxhero01.a.inova.com.br) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1legam-00052d-8h for pgsql-performance@lists.postgresql.org; Thu, 06 May 2021 16:11:16 +0000 Received: from MXHERO01.A.INOVA.COM.BR (localhost [127.0.0.1]) by mxhero01.a.inova.com.br (Postfix) with ESMTP id 49FDD261728 for ; Thu, 6 May 2021 16:11:10 +0000 (UTC) Received: from corpmoutpolicyd01.a.inova.com.br (ip-10-0-1-88.ec2.internal [10.0.1.88]) by mxhero02.a.inova.com.br (Postfix) with ESMTP; Thu, 6 May 2021 16:11:10 +0000 (UTC) Received: from corpmoutpolicyd01.a.inova.com.br (localhost [127.0.0.1]) by corpmoutpolicyd01.a.inova.com.br (Postfix) with ESMTP id 392912205AD; Thu, 6 May 2021 13:11:07 -0300 (BRT) Received: from corpmout01.a.inova.com.br (ip-10-0-1-125.ec2.internal [10.0.1.125]) by corpmoutpolicyd01.a.inova.com.br (Postfix) with ESMTP id 30FD9C30B2; Thu, 6 May 2021 13:11:07 -0300 (BRT) Received: from corpmbox02.a.inova.com.br (ip-10-0-4-158.ec2.internal [10.0.4.158]) by corpmout01.a.inova.com.br (Postfix) with ESMTP; Thu, 6 May 2021 13:11:07 -0300 (-03) Date: Thu, 6 May 2021 13:11:07 -0300 (BRT) From: luis.roberto@siscobra.com.br To: Semen Yefimenko Cc: pgsql-performance Message-ID: <1368981627.1376962.1620317467043.JavaMail.zimbra@siscobra.com.br> In-Reply-To: References: Subject: Re: Very slow Query compared to Oracle / SQL - Server MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.0.4.158] X-Mailer: Zimbra 8.8.15_GA_4018 (ZimbraWebClient - GC90 (Win)/8.8.15_GA_4007) Thread-Topic: Very slow Query compared to Oracle / SQL - Server Thread-Index: TnYV9fjTd75cEXIRtQuzkFqeC8NwFw== x-mxHero-Origin-Ip: /10.0.4.78:55414 X-mxHero-AttachmentBlock: rule=48;result=false List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ----- Mensagem original ----- > De: "Semen Yefimenko" > Para: "pgsql-performance" > Enviadas: Quinta-feira, 6 de maio de 2021 11:38:39 > Assunto: Very slow Query compared to Oracle / SQL - Server > SELECT column1,..., column54 where ((entrytype = 4000 or entrytype = 4001 or > entrytype = 4002) and (archivestatus <= 1)) order by timestampcol desc; The first thing I would try is rewriting the query to: SELECT column1,..., column54 FROM logtable WHERE (entrytype in (4000,4001,4002)) AND (archivestatus <= 1)) ORDER BY timestampcol DESC; Check if that makes a difference... Luis R. Weck