Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hBDP9-0006V7-E7 for pgsql-performance@arkaria.postgresql.org; Tue, 02 Apr 2019 07:00:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hBDP8-0008Ly-1c for pgsql-performance@arkaria.postgresql.org; Tue, 02 Apr 2019 07:00:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from <6220104@qq.com>) id 1hBDP7-0008Lr-PL for pgsql-performance@lists.postgresql.org; Tue, 02 Apr 2019 07:00:17 +0000 Received: from n3.nabble.com ([162.255.23.22]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from <6220104@qq.com>) id 1hBDP1-0005mG-3f for pgsql-performance@postgresql.org; Tue, 02 Apr 2019 07:00:17 +0000 Received: from n3.nabble.com (localhost [127.0.0.1]) by n3.nabble.com (Postfix) with ESMTP id 16EBB1300A220 for ; Tue, 2 Apr 2019 00:00:09 -0700 (MST) Date: Tue, 2 Apr 2019 00:00:09 -0700 (MST) From: "tank.zhang" <6220104@qq.com> To: pgsql-performance@postgresql.org Message-ID: <1554188409091-0.post@n3.nabble.com> In-Reply-To: References: <1554111914781-0.post@n3.nabble.com> Subject: Re: Postgresql Sort cost Poor performance? MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 1=E3=80=81DISTINCT response time is fast without being added =20 qis3_dp2=3D# SELECT COUNT(*) AS CHECKCARNUM FROM QIS_CARPASSEDSTATION A WHE= RE 1=3D1 AND A.SSTATIONCD =3D 'VQ3_LYG' AND A.SLINENO IN ( '1F' , '2F' , '3F' = ) AND A.DWORKDATE >=3D TO_DATE('2017-02-11','YYYY-MM-DD') AND A.DWORKDATE <=3D TO_DATE('2019-03-11','YYYY-MM-DD'); checkcarnum=20 ------------- 2142215 (1 row) *Time: 2237.970 ms (00:02.238)* qis3_dp2=3D#=20 2=E3=80=81 Adding a DISTINCT response time was very slow qis3_dp2=3D# SELECT COUNT(DISTINCT SVIN) AS CHECKCARNUM FROM QIS_CARPASSEDSTATION A WHERE 1=3D1 AND A.SSTATIONCD =3D 'VQ3_LYG' AND A.SLI= NENO IN ( '1F' , '2F' , '3F' ) AND A.DWORKDATE >=3D TO_DATE('2017-02-11','YYYY-MM-DD') AND A.DWORKDATE <=3D TO_DATE('2019-03-11','YYYY-MM-DD'); checkcarnum=20 ------------- 1071367 (1 row) *Time: 38979.246 ms (00:38.979)* -- Sent from: http://www.postgresql-archive.org/PostgreSQL-performance-f205008= 1.html