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 1nfehB-0002s0-Mv for pgsql-admin@arkaria.postgresql.org; Sat, 16 Apr 2022 09:26:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nfeh9-0002O2-N3 for pgsql-admin@arkaria.postgresql.org; Sat, 16 Apr 2022 09:26:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nfeh9-0002Lz-8I for pgsql-admin@lists.postgresql.org; Sat, 16 Apr 2022 09:26:19 +0000 Received: from mail-vs1-xe34.google.com ([2607:f8b0:4864:20::e34]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nfeh6-0001ri-6u for pgsql-admin@lists.postgresql.org; Sat, 16 Apr 2022 09:26:18 +0000 Received: by mail-vs1-xe34.google.com with SMTP id j16so8745252vsv.2 for ; Sat, 16 Apr 2022 02:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3MuxyGOx5dAG2uSIBWH2U9QnH0Q/B6guYqQdRSIvOBs=; b=mUASR6kLmQJ8IdLnXQi6aoksWLlHFbZiQ0cdsUznHPq51qthPxl6vPJtHfxesWdRUb qnhItxCZjjMu6KsoJYN2asXQGeO6I8VhRllB8uVG7coJegT/faosBNgiwRkgD9Lv6OZ4 /qX+wfzcydmyxZkbUTLZl9dhtx0SlWoTnSUUlXm3OXvcfiXkQJUOq9qmWy4pu/0wEftr qIeNmK23XqwktIG+YqU0Nrk/7tYP4VBPkfP9V0c0BbP3oZOKxSIg3BOy9rESLVM4Iwt+ YDvk6U/bFC1WCYU/MEDUg4WZdDBs2yIY+wtg4IzHcojtSSjXfIiT/rnqJBknSxTqZVHD rTOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3MuxyGOx5dAG2uSIBWH2U9QnH0Q/B6guYqQdRSIvOBs=; b=3+HzMj/8Jqu98WK6pUCtDgiw5X2adhoozgnoQWEvemKxLm/5TbsrqLDcLpqfa0mi8M eF597JmVI9uzmr/cYNY3yW/zFPmVtMEjFVJTYzj2eeAbnGYgNOIO99itiXqixNSt+PlI fSFZtDFIikO9M2SeqaTumsW43HBbaeHZWWQ/g0NNHZYjWEtTlPG6nUXRaQ+T+hD763kK OtYY0YmPL2eGo0O4TxOe1yVueKg8mSmC4pZzpH+hbBMI1ILD57oC9qdFBwjGB5XWWgKL r42vqfYJWWfKwrRoqSyuYRRv4VGylf4IbnBWGWW3ip/Ya358d00W5N3BQHflE57PKj7R GosQ== X-Gm-Message-State: AOAM532vJNeD0Xg4Tu3YvezI27AtwuExINFSRGT+EafarUF8bV3iWwSG 9z8gYmLWS6xW1UOXxs/bTQRZX1t/fWtJTBTi5vc= X-Google-Smtp-Source: ABdhPJw9AwB01LJQWfPDWaXIQQIxJU2g03boX5y4OwpL9S46z2eJY9FUi2Evac25gJoG3PqVw/dx7q6Zl64mjn8klP0= X-Received: by 2002:a05:6102:417:b0:32a:288d:997a with SMTP id d23-20020a056102041700b0032a288d997amr704790vsq.25.1650101173698; Sat, 16 Apr 2022 02:26:13 -0700 (PDT) MIME-Version: 1.0 References: <180318918b0.2923.9bfe8bcc586ac955e423c0e3d5444448@pscs.co.uk> In-Reply-To: <180318918b0.2923.9bfe8bcc586ac955e423c0e3d5444448@pscs.co.uk> From: Kenny Bachman Date: Sat, 16 Apr 2022 12:26:02 +0300 Message-ID: Subject: Re: postgresql-14 slow query To: jeff.janes@gmail.com, Paul Smith , avinash.vallarapu@gmail.com, bbabu12@gmail.com, mav@wastegate.net Cc: pgsql-admin@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000004d42fd05dcc21eed" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000004d42fd05dcc21eed Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank you for your all e-mails. I want to provide more information about the query and table. Table count(*) is =3D 24M is_false column doesn't selectivity, so is_false=3D0 count(*) is ~24M. My work _mem is 64MB Also, my original query is below. I changed the query to ( distinct on ) in order to avoid hashaggregate. SELECT order_history.order_id, max(order_history.creation_date) AS c_date FROM work.order_history WHERE (order_history.state_id =3D ANY (ARRAY[30, 51, 63, 136, 195, 233, 348])) AND order_history.is_false =3D 0 GROUP BY order_history.order_id; EXPLAIN (ANALYZE ,BUFFERS) SELECT order_history.order_id, max(order_history.creation_date) AS c_date FROM work.order_history WHERE (order_history.state_id =3D ANY (ARRAY[30, 51, 63, 136, 195, 233, 348])) AND order_history.is_false =3D 0 GROUP BY order_history.order_id; QUERY PLAN ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= -------- Finalize HashAggregate (cost=3D572423.43..574487.66 rows=3D206423 width= =3D12) (actual time=3D2579.826..3394.787 rows=3D2049357 loops=3D1) Group Key: order_id Batches: 5 Memory Usage: 65585kB Disk Usage: 56504kB Buffers: shared hit=3D350539, temp read=3D6850 written=3D12167 -> Gather (cost=3D483661.54..568294.97 rows=3D825692 width=3D12) (actu= al time=3D1650.341..1961.442 rows=3D2085884 loops=3D1) Workers Planned: 4 Workers Launched: 4 Buffers: shared hit=3D350539 -> Partial HashAggregate (cost=3D482661.54..484725.77 rows=3D206= 423 width=3D12) (actual time=3D1641.882..1730.569 rows=3D417177 loops=3D5) Group Key: order_id Batches: 1 Memory Usage: 61457kB Buffers: shared hit=3D350539 Worker 0: Batches: 1 Memory Usage: 45073kB Worker 1: Batches: 1 Memory Usage: 57361kB Worker 2: Batches: 1 Memory Usage: 57361kB Worker 3: Batches: 1 Memory Usage: 61457kB -> Parallel Seq Scan on order_history (cost=3D0.00..473993.00 rows=3D1733707 width=3D12) (actual time=3D0.025..1= 279.366 rows=3D1378310 loops=3D5) Filter: ((is_false =3D 0) AND (state_id =3D ANY ('{30,51,63,136,195,233,348}'::integer[]))) Rows Removed by Filter: 3268432 Buffers: shared hit=3D350539 Planning: Buffers: shared hit=3D7 Planning Time: 0.644 ms Execution Time: 3482.662 ms And the execution plan after creating an index; CREATE INDEX ON work.order_history (state_id ,order_id); CREATE INDEX ANALYZE work.order_history; ANALYZE EXPLAIN (ANALYZE ,BUFFERS) SELECT order_history.order_id, max(order_history.creation_date) AS c_date FROM work.order_history WHERE (order_history.state_id =3D ANY (ARRAY[30, 51, 63, 136, 195, 233, 348])) AND order_history.is_false =3D 0 GROUP BY order_history.order_id; QUERY PLAN ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= --------------------------------------------------- HashAggregate (cost=3D558809.02..560882.30 rows=3D207328 width=3D12) (act= ual time=3D6050.759..7598.165 rows=3D2049357 loops=3D1) Group Key: order_id Batches: 5 Memory Usage: 65585kB Disk Usage: 226272kB Buffers: shared hit=3D6007222 read=3D9864, temp read=3D28099 written=3D4= 9004 -> Index Scan using order_history_state_id_order_id_idx on order_history (cost=3D0.44..524241.93 rows=3D6913417 width=3D12) (actual time=3D0.079..4137.626 rows=3D6891551 loops=3D1) Index Cond: (state_id =3D ANY ('{30,51,63,136,195,233,348}'::integer[])) Filter: (is_false =3D 0) Rows Removed by Filter: 5301 Buffers: shared hit=3D6007222 read=3D9864 Planning: Buffers: shared hit=3D53 read=3D2 Planning Time: 0.634 ms Execution Time: 7695.625 ms Paul Smith , 16 Nis 2022 Cmt, 11:47 tarihinde =C5=9Funu ya= zd=C4=B1: > "for fun" try doing > > Set enable_seqscan=3Doff > > And try the queries again. This will discourage it from doing sequential > scans and use indexes if possible. If it still does a sequential scan, th= en > there's some reason it can't use the indexes. If it uses indexes now, the= n > the planner must think that the sequential scan would be quicker > > On 15 April 2022 22:00:07 Kenny Bachman wrote= : > >> Hello Team, >> >> How can I tune this query? It got even slower when I created the index >> for (state_id, order_id desc). The following explain analyze output is >> without an index. It takes 13 seconds if I create that index. Could you >> help me? >> >> Thank you so much for your help. >> >> SELECT DISTINCT ON (order_history.order_id) order_id, >> order_history.creation_date AS c_date >> FROM work.order_history WHERE (order_history.state_id =3D ANY (ARRAY[30, >> 51, 63, 136, 195, 233, 348])) AND order_history.is_false =3D 0 >> ORDER BY order_history.order_id DESC; >> >> EXPLAIN ANALYZE output: >> >> Unique (cost=3D672007.46..1519683.55 rows=3D206423 width=3D12) (actual >> time=3D1701.420..3439.095 rows=3D2049357 loops=3D1) >> -> Gather Merge (cost=3D672007.46..1502346.48 rows=3D6934827 width= =3D12) >> (actual time=3D1701.419..2989.243 rows=3D6891551 loops=3D1) >> Workers Planned: 4 >> Workers Launched: 4 >> -> Sort (cost=3D671007.40..675341.67 rows=3D1733707 width=3D1= 2) >> (actual time=3D1657.609..1799.723 rows=3D1378310 loops=3D5) >> Sort Key: order_id DESC >> Sort Method: external merge Disk: 38960kB >> Worker 0: Sort Method: external merge Disk: 31488kB >> Worker 1: Sort Method: external merge Disk: 36120kB >> Worker 2: Sort Method: external merge Disk: 31368kB >> Worker 3: Sort Method: external merge Disk: 36152kB >> -> Parallel Seq Scan on order_history >> (cost=3D0.00..473993.00 rows=3D1733707 width=3D12) (actual time=3D0.041= ..1211.485 >> rows=3D1378310 loops=3D5) >> Filter: ((is_false =3D 0) AND (state_id =3D ANY >> ('{30,51,63,136,195,233,348}'::integer[]))) >> Rows Removed by Filter: 3268432 >> Planning Time: 0.405 ms >> Execution Time: 3510.433 ms >> > > > -- > > Paul Smith Computer Services > Tel: 01484 855800 > Vat No: GB 685 6987 53 > > Sign up for news & updates > --0000000000004d42fd05dcc21eed Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thank you for your all e-mails. I want to provide more inf= ormation about the query and table.
Table count(*) is =3D=C2=A024M
is_false column doesn't selectivity, so is_false=3D0 count(*) is = ~24M.
My work _mem is 64MB

Also, my orig= inal query is below. I changed the query to ( distinct on ) in order to avo= id hashaggregate.

SELECT order_history.order_id,max(order_history.creation_date) AS c_date
FROM work.order_history
= WHERE (order_history.state_id =3D ANY (ARRAY[30, 51, 63, 136, 195, 233, 348= ])) AND order_history.is_false =3D 0
GROUP BY order_history.order_id;

EXPLAIN (ANALYZE ,BUFFERS) SELECT order_history.= order_id,
max(order_history.creation_date) AS c_date
FROM work.order_= history
WHERE (order_history.state_id =3D ANY (ARRAY[30, 51, 63, 136, 19= 5, 233, 348])) AND order_history.is_false =3D 0
GROUP BY order_history.o= rder_id;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 QUERY PLAN =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0
-----------------------------------------------= ---------------------------------------------------------------------------= ------------------------------------
=C2=A0Finalize HashAggregate =C2=A0= (cost=3D572423.43..574487.66 rows=3D206423 width=3D12) (actual time=3D2579.= 826..3394.787 rows=3D2049357 loops=3D1)
=C2=A0 =C2=A0Group Key: order_id=
=C2=A0 =C2=A0Batches: 5 =C2=A0Memory Usage: 65585kB =C2=A0Disk Usage: 5= 6504kB
=C2=A0 =C2=A0Buffers: shared hit=3D350539, temp read=3D6850 writt= en=3D12167
=C2=A0 =C2=A0-> =C2=A0Gather =C2=A0(cost=3D483661.54..5682= 94.97 rows=3D825692 width=3D12) (actual time=3D1650.341..1961.442 rows=3D20= 85884 loops=3D1)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Workers Planned: 4=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Workers Launched: 4
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0Buffers: shared hit=3D350539
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0-> =C2=A0Partial HashAggregate =C2=A0(cost=3D482661.54..484725= .77 rows=3D206423 width=3D12) (actual time=3D1641.882..1730.569 rows=3D4171= 77 loops=3D5)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Gro= up Key: order_id
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= Batches: 1 =C2=A0Memory Usage: 61457kB
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0Buffers: shared hit=3D350539
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Worker 0: =C2=A0Batches: 1 =C2=A0Memo= ry Usage: 45073kB
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0Worker 1: =C2=A0Batches: 1 =C2=A0Memory Usage: 57361kB
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Worker 2: =C2=A0Batches: 1 =C2=A0M= emory Usage: 57361kB
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0Worker 3: =C2=A0Batches: 1 =C2=A0Memory Usage: 61457kB
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-> =C2=A0Parallel Seq Scan = on order_history =C2=A0(cost=3D0.00..473993.00 rows=3D1733707 width=3D12) (= actual time=3D0.025..1279.366 rows=3D1378310 loops=3D5)
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Filter: ((is_= false =3D 0) AND (state_id =3D ANY ('{30,51,63,136,195,233,348}'::i= nteger[])))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0Rows Removed by Filter: 3268432
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Buffers: shared hit= =3D350539
=C2=A0Planning:
=C2=A0 =C2=A0Buffers: shared hit=3D7
=C2= =A0Planning Time: 0.644 ms
=C2=A0Execution Time: 3482.662 ms


And the execution plan after creating an i= ndex;

CREATE INDEX ON work.order_history (state_id= ,order_id);
CREATE INDEX
ANALYZE work.order_history;
ANALYZE
E= XPLAIN (ANALYZE ,BUFFERS) SELECT order_history.order_id,
max(order_histo= ry.creation_date) AS c_date
FROM work.order_history
WHERE (order_hist= ory.state_id =3D ANY (ARRAY[30, 51, 63, 136, 195, 233, 348])) AND order_his= tory.is_false =3D 0
GROUP BY order_history.order_id;
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0QUERY PLAN =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0
-----------------------------------------------------------------= ---------------------------------------------------------------------------= -------------------------------------------------------------
=C2=A0Hash= Aggregate =C2=A0(cost=3D558809.02..560882.30 rows=3D207328 width=3D12) (act= ual time=3D6050.759..7598.165 rows=3D2049357 loops=3D1)
=C2=A0 =C2=A0Gro= up Key: order_id
=C2=A0 =C2=A0Batches: 5 =C2=A0Memory Usage: 65585kB =C2= =A0Disk Usage: 226272kB
=C2=A0 =C2=A0Buffers: shared hit=3D6007222 read= =3D9864, temp read=3D28099 written=3D49004
=C2=A0 =C2=A0-> =C2=A0Inde= x Scan using order_history_state_id_order_id_idx on order_history =C2=A0(co= st=3D0.44..524241.93 rows=3D6913417 width=3D12) (actual time=3D0.079..4137.= 626 rows=3D6891551 loops=3D1)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Index Co= nd: (state_id =3D ANY ('{30,51,63,136,195,233,348}'::integer[]))=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Filter: (is_false =3D 0)
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0Rows Removed by Filter: 5301
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0Buffers: shared hit=3D6007222 read=3D9864
=C2=A0Plannin= g:
=C2=A0 =C2=A0Buffers: shared hit=3D53 read=3D2
=C2=A0Planning Time= : 0.634 ms
=C2=A0Execution Time: 7695.625 ms

Paul Smith <paul@pscs.co.uk>, 16 Nis 2022 Cmt, 1= 1:47 tarihinde =C5=9Funu yazd=C4=B1:
"for fun" try doing=C2=A0

Set enable_seqscan=3Doff

And try the queries again. This will discour= age it from doing sequential scans and use indexes if possible. If it still= does a sequential scan, then there's some reason it can't use the = indexes. If it uses indexes now, then the planner must think that the seque= ntial scan would be quicker=C2=A0

On 15 April 2022 22:00:07 Kenny Bachman <kenny.bachman17@gmail.com> wrote:=

Hello Team,

How can I tune this query? = It got even slower when I created the index for (state_id, order_id desc). = The following explain analyze output is without=C2=A0an=C2=A0index. It take= s 13 seconds if I create that index. Could you help me?

Thank you so much for your help.

SELECT DIST= INCT ON (order_history.order_id) order_id, order_history.creation_date =C2= =A0AS c_date
FROM work.order_history WHERE (order_history.state_id =3D A= NY (ARRAY[30, 51, 63, 136, 195, 233, 348])) AND order_history.is_false =3D = 0
ORDER BY order_history.order_id DESC;

EXP= LAIN ANALYZE output:

=C2=A0Unique =C2=A0(cost=3D67= 2007.46..1519683.55 rows=3D206423 width=3D12) (actual time=3D1701.420..3439= .095 rows=3D2049357 loops=3D1)
=C2=A0 =C2=A0-> =C2=A0Gather Merge =C2= =A0(cost=3D672007.46..1502346.48 rows=3D6934827 width=3D12) (actual time=3D= 1701.419..2989.243 rows=3D6891551 loops=3D1)
=C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0Workers Planned: 4
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Workers Laun= ched: 4
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-> =C2=A0Sort =C2=A0(cost= =3D671007.40..675341.67 rows=3D1733707 width=3D12) (actual time=3D1657.609.= .1799.723 rows=3D1378310 loops=3D5)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0Sort Key: order_id DESC
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0Sort Method: external merge =C2=A0Disk: 38960kB<= br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Worker 0: =C2=A0S= ort Method: external merge =C2=A0Disk: 31488kB
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Worker 1: =C2=A0Sort Method: external merge = =C2=A0Disk: 36120kB
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0Worker 2: =C2=A0Sort Method: external merge =C2=A0Disk: 31368kB
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Worker 3: =C2=A0Sort Me= thod: external merge =C2=A0Disk: 36152kB
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0-> =C2=A0Parallel Seq Scan on order_history =C2= =A0(cost=3D0.00..473993.00 rows=3D1733707 width=3D12) (actual time=3D0.041.= .1211.485 rows=3D1378310 loops=3D5)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Filter: ((is_false =3D 0) AND (sta= te_id =3D ANY ('{30,51,63,136,195,233,348}'::integer[])))
=C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Rows = Removed by Filter: 3268432
=C2=A0Planning Time: 0.405 ms
=C2=A0Execut= ion Time: 3510.433 ms


=09
--

=09
Paul Smith Computer Services
Tel: 01484 855800
Vat No: GB 685 6987 53

=09
--0000000000004d42fd05dcc21eed--