pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: gzh <gzhcoder@126.com>
To: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: How to improve the performance of my SQL query?
Date: Tue, 25 Jul 2023 11:11:13 +0800 (CST)
Message-ID: <6cd42bea.2647.1898b07865a.Coremail.gzhcoder@126.com> (raw)
In-Reply-To: <ca1e00239309c95c63157941facdbb4b80a798da.camel@cybertec.at>
References: <6212ea1b.425b.1897221c3cc.Coremail.gzhcoder@126.com>
	<369ee851ef59bc84190f1631219b5a0c8f7907e9.camel@cybertec.at>
	<1937d056.71e9.18973a752d0.Coremail.gzhcoder@126.com>
	<ea3893a955f4ae396efb05260bfab056f027fcf9.camel@cybertec.at>
	<6f3fd2f9.12b3.189761e1ccc.Coremail.gzhcoder@126.com>
	<4ae89a642b8ee57b8fdcd2f6e106aadc1eb60a4b.camel@cybertec.at>
	<66883f7d.6d50.189875236b2.Coremail.gzhcoder@126.com>
	<ca1e00239309c95c63157941facdbb4b80a798da.camel@cybertec.at>




>I asked for EXPLAIN (ANALYZE, BUFFERS, SETTINGS) ...

>Or do you have a version that is too old for SETTINGS?

Sorry. Please refer to the following execution plan.




EXPLAIN (ANALYZE, BUFFERS, SETTINGS) 

select COUNT(ET_CD)

from TBL_SHA

WHERE TBL_SHA.MS_CD = 'MLD009'

and TBL_SHA.ETRYS in

   (select TBL_INF.RY_CD

    from TBL_INF

    WHERE TBL_INF.MS_CD = 'MLD009'

   AND TBL_INF.RY_CD = '00000001'

   )




----- Execution Plan -----

  Buffers: shared hit=13 read=2171693

  I/O Timings: read=365863.877

  ->  Aggregate  (cost=2728633.22..2728633.23 rows=1 width=8) (actual time=131595.624..131599.529 rows=1 loops=1)

        Buffers: shared hit=13 read=2171693

        I/O Timings: read=365863.877

        ->  Nested Loop  (cost=1000.29..2722556.76 rows=2430587 width=9) (actual time=2.341..131256.445 rows=2513500 loops=1)

              Buffers: shared hit=13 read=2171693

              I/O Timings: read=365863.877

              ->  Index Only Scan using tbl_inf_pkc on tbl_inf  (cost=0.29..8.31 rows=1 width=9) (actual time=1.471..1.476 rows=1 loops=1)

                    Index Cond: ((ms_cd = 'MLD009'::bpchar) AND (ry_cd = '00000001'::bpchar))

                    Heap Fetches: 1

                    Buffers: shared hit=2 read=2

                    I/O Timings: read=1.412

              ->  Gather  (cost=1000.00..2698242.58 rows=2430587 width=18) (actual time=0.866..130696.440 rows=2513500 loops=1)

                    Workers Planned: 2

                    Workers Launched: 2

                    Buffers: shared hit=11 read=2171691

                    I/O Timings: read=365862.464

                    ->  Parallel Seq Scan on tbl_sha  (cost=0.00..2454183.88 rows=1012745 width=18) (actual time=0.215..130476.981 rows=837833 loops=3)

                          Filter: ((ms_cd = 'MLD009'::bpchar) AND (etrys = '00000001'::bpchar))

                          Rows Removed by Filter: 13728945

                          Buffers: shared hit=11 read=2171691

                          I/O Timings: read=365862.464

Settings: effective_cache_size = '1886088kB', jit = 'off', search_path = '"$user", mdb'

Planning:

  Buffers: shared hit=167 read=7

  I/O Timings: read=2.735

Planning Time: 3.733 ms

Execution Time: 131599.594 ms











At 2023-07-24 23:58:50, "Laurenz Albe" <laurenz.albe@cybertec.at> wrote:
>On Mon, 2023-07-24 at 17:54 +0800, gzh wrote:
>> EXPLAIN (ANALYZE ON, VERBOSE ON, COSTS ON, BUFFERS ON) 
>
>I asked for EXPLAIN (ANALYZE, BUFFERS, SETTINGS) ...
>Or do you have a version that is too old for SETTINGS?
>
>One other idea: check if the index is INVALID (this will
>be visible if you run "\d tablenane" in "psql").
>Invalid indexes won't be used.
>
>Yours,
>Laurenz Albe


view thread (7+ messages)  latest in thread

Message-ID: <6cd42bea.2647.1898b07865a.Coremail.gzhcoder@126.com>
Permalink:  ../6cd42bea.2647.1898b07865a.Coremail.gzhcoder@126.com/
Also on:    postgresql.org/message-id/6cd42bea.2647.1898b07865a.Coremail.gzhcoder@126.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: gzhcoder@126.com, laurenz.albe@cybertec.at
  Subject: Re: How to improve the performance of my SQL query?
  In-Reply-To: <6cd42bea.2647.1898b07865a.Coremail.gzhcoder@126.com>
  References: <6212ea1b.425b.1897221c3cc.Coremail.gzhcoder@126.com> <369ee851ef59bc84190f1631219b5a0c8f7907e9.camel@cybertec.at> <1937d056.71e9.18973a752d0.Coremail.gzhcoder@126.com> <ea3893a955f4ae396efb05260bfab056f027fcf9.camel@cybertec.at> <6f3fd2f9.12b3.189761e1ccc.Coremail.gzhcoder@126.com> <4ae89a642b8ee57b8fdcd2f6e106aadc1eb60a4b.camel@cybertec.at> <66883f7d.6d50.189875236b2.Coremail.gzhcoder@126.com> <ca1e00239309c95c63157941facdbb4b80a798da.camel@cybertec.at> <6cd42bea.2647.1898b07865a.Coremail.gzhcoder@126.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox