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 1lSlrY-0000hl-R4 for pgsql-general@arkaria.postgresql.org; Sat, 03 Apr 2021 19:23:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lSlrX-0005CH-AB for pgsql-general@arkaria.postgresql.org; Sat, 03 Apr 2021 19:23:15 +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 1lSlKR-0004Gg-0u for pgsql-general@lists.postgresql.org; Sat, 03 Apr 2021 18:49:04 +0000 Received: from new3-smtp.messagingengine.com ([66.111.4.229]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lSlKN-0002H6-Vl for pgsql-general@postgresql.org; Sat, 03 Apr 2021 18:49:01 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.nyi.internal (Postfix) with ESMTP id 168C3580A3D for ; Sat, 3 Apr 2021 14:48:59 -0400 (EDT) Received: from imap7 ([10.202.2.57]) by compute2.internal (MEProxy); Sat, 03 Apr 2021 14:48:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h= mime-version:message-id:date:from:to:subject:content-type; s= fm2; bh=fPc1Sw8S+2IRvLaS9tZ1RY2nw9d2bCF+rzHlVK4vdXA=; b=Gk1tL69e f8bK0AOZtGg0W4v0WCDdR8X5+ZksYirrb6JwMRheGGdUOPgeXOHRcWc7R4pespLp SgxGk0aRLIEdYMCIDuJieMJp7j6Ks2c8YcdQ7IsOolJK/ATtSNrKqrb/3j1yOeDY DkwHi4cC4Z6IJ6xngN5LyJ7rEyVD8ovuIHO4pFXIHAVZx80FJJPVqGT1HwavhVZ+ MTb4L/J3Vv1p2r1xoe3eebjmeVjJ8hicSkBofhqjeL1MBrPrPMk0OL82u37SXn/a xxnktEdpsHufk71TskAWxsIb9LFAsb/55NR+jSXuJfsQVsl7yhqyzTFlR4yYcjmY ZIQvsSRCpGB0rA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=fPc1Sw8S+2IRvLaS9tZ1RY2nw9d2b CF+rzHlVK4vdXA=; b=l+tRtr+hL9e+r9P1iYQHne9E850+SGuVuSSLcJnsNIeLx sMJ566hW7xVzvry7zHhUvm76MPCWYmo04P9L5YJBrALkUBVQLbacNRHJ7nEsyoww PEk3/ufDya5Pawajo0kGafjWyi/uJPqbAuWqL0i7vuW00+M6bSgPfCSn8wfwl+jX nh1qaQwDGVhcYy8dQLbfGQ+vCMKr4VeTt9DUuxzKF5+QFwRMDljbZwrEmFbLpQrZ WS7rcHKDCLKaejwu3i64/hMGvtDX2E+8C1652kmnmXjRsYn8khIbkSUz4APEyeoR +peM81kjOkcDvPlfeRWncMfJJoItavRGa08VnGIfQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudeikedgudefhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkfffhvffutgesrgdtre erreerjeenucfhrhhomhepfdflohhhnhcuifgrrhhrihhsohhnfdcuoehjohhhnhhgrghr rhhishhonhesfhgrshhtmhgrihhlrdgtohhmqeenucggtffrrghtthgvrhhnpeffgeduvd efffdvvdefffdtheduieeufeevfeegtdetffelieffieefuefftdehjeenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjohhhnhhgrghrrhhish honhesfhgrshhtmhgrihhlrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 7E48236005F; Sat, 3 Apr 2021 14:48:58 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-273-g8500d2492d-fm-20210323.002-g8500d249 Mime-Version: 1.0 Message-Id: <8fbdc8f4-8228-4ee2-a2fc-3ba13aa5e5e2@www.fastmail.com> Date: Sat, 03 Apr 2021 11:48:12 -0700 From: "John Garrison" To: pgsql-general@postgresql.org Subject: =?UTF-8?Q?What_is_the_expected_difference_in_performance_between_queryin?= =?UTF-8?Q?g_a_all_partitions_of_a_partitioned_table_and_non_partitioned?= =?UTF-8?Q?_one=3F?= Content-Type: multipart/alternative; boundary=16dd1e6247954416a7de5995ef0ed3f5 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --16dd1e6247954416a7de5995ef0ed3f5 Content-Type: text/plain Hi there, my question is, shouldn't a query that spans all partitions in a partionend table be roughly the same in performance as one on a non partionend table? I'm getting roughly 50% slower performance on a partioned table. I have tried this on a macbook and ubuntu server. More details are below. The queries: EXPLAIN (ANALYZE, VERBOSE, BUFFERS, COSTS) SELECT COUNT(*) FROM logs WHERE event = 'rewinded'; EXPLAIN (ANALYZE, VERBOSE, BUFFERS, COSTS) SELECT COUNT(*) FROM logs_partioned WHERE event = 'rewinded'; ---- The results: EXPLAIN (ANALYZE, VERBOSE, BUFFERS, COSTS) SELECT COUNT(*) FROM logs WHERE event = 'rewinded'; QUERY PLAN Finalize Aggregate (cost=93673.28..93673.29 rows=1 width=8) (actual time=163.160..164.321 rows=1 loops=1) Output: count(*) Buffers: shared hit=6929 -> Gather (cost=93672.86..93673.27 rows=4 width=8) (actual time=163.088..164.314 rows=4 loops=1) Output: (PARTIAL count(*)) Workers Planned: 4 Workers Launched: 3 Buffers: shared hit=6929 -> Partial Aggregate (cost=92672.86..92672.87 rows=1 width=8) (actual time=154.476..154.477 rows=1 loops=4) Output: PARTIAL count(*) Buffers: shared hit=6929 Worker 0: actual time=150.627..150.628 rows=1 loops=1 Buffers: shared hit=1725 Worker 1: actual time=152.368..152.368 rows=1 loops=1 Buffers: shared hit=1718 Worker 2: actual time=152.219..152.220 rows=1 loops=1 Buffers: shared hit=1727 -> Parallel Index Only Scan using logs_event_idx on public.logs (cost=0.57..87681.79 rows=1996428 width=0) (actual time=0.101..90.809 rows=1976526 loops=4) Output: event Index Cond: (logs.event = 'rewinded'::text) Heap Fetches: 854 Buffers: shared hit=6929 Worker 0: actual time=0.155..88.693 rows=1959750 loops=1 Buffers: shared hit=1725 Worker 1: actual time=0.106..89.503 rows=1969110 loops=1 Buffers: shared hit=1718 Worker 2: actual time=0.102..89.430 rows=1973790 loops=1 Buffers: shared hit=1727 Planning Time: 0.242 ms Execution Time: 164.383 ms (30 rows) Time: 165.105 ms ------- EXPLAIN (ANALYZE, VERBOSE, BUFFERS, COSTS) SELECT COUNT(*) FROM logs_partioned WHERE event = 'rewinded'; QUERY PLAN Finalize Aggregate (cost=110643.80..110643.81 rows=1 width=8) (actual time=249.562..250.597 rows=1 loops=1) Output: count(*) Buffers: shared hit=6889 -> Gather (cost=110643.48..110643.79 rows=3 width=8) (actual time=249.522..250.593 rows=4 loops=1) Output: (PARTIAL count(*)) Workers Planned: 3 Workers Launched: 3 Buffers: shared hit=6889 -> Partial Aggregate (cost=109643.48..109643.49 rows=1 width=8) (actual time=240.213..240.214 rows=1 loops=4) Output: PARTIAL count(*) Buffers: shared hit=6889 Worker 0: actual time=237.259..237.260 rows=1 loops=1 Worker 0: actual time=237.259..237.260 rows=1 loops=1 Buffers: shared hit=1678 Worker 1: actual time=237.244..237.245 rows=1 loops=1 Buffers: shared hit=1768 Worker 2: actual time=237.304..237.305 rows=1 loops=1 Buffers: shared hit=1699 -> Parallel Append (cost=0.44..103381.36 rows=2504849 width=0) (actual time=0.132..183.045 rows=1976526 loops=4) Buffers: shared hit=6889 Worker 0: actual time=0.171..179.435 rows=1951389 loops=1 Buffers: shared hit=1678 Worker 1: actual time=0.160..181.963 rows=1954680 loops=1 Buffers: shared hit=1768 Worker 2: actual time=0.159..181.714 rows=1976309 loops=1 Buffers: shared hit=1699 -> Parallel Index Only Scan using logs_partioned_p2_event_idx on public.logs_partioned_p2 logs_partioned_2 (cost=0.44..23064.91 rows=638123 width=0) (actual time=0.129..47.947 rows=981544 loops=2) Index Cond: (logs_partioned_2.event = 'rewinded'::text) Heap Fetches: 0 Buffers: shared hit=1690 Worker 0: actual time=0.171..95.322 rows=1951389 loops=1 Buffers: shared hit=1678 Worker 1: actual time=0.087..0.571 rows=11700 loops=1 Buffers: shared hit=12 -> Parallel Index Only Scan using logs_partioned_p4_event_idx on public.logs_partioned_p4 logs_partioned_4 (cost=0.44..22982.75 rows=635850 width=0) (actual time=0.054..31.451 rows=663060 loops=3) Index Cond: (logs_partioned_4.event = 'rewinded'::text) Heap Fetches: 0 Buffers: shared hit=1712 Worker 1: actual time=0.001..0.001 rows=0 loops=1 Buffers: shared hit=1 Worker 2: actual time=0.158..93.844 rows=1976309 loops=1 Buffers: shared hit=1699 -> Parallel Index Only Scan using logs_partioned_p3_event_idx on public.logs_partioned_p3 logs_partioned_3 (cost=0.44..22398.42 rows=610946 width=0) (actual time=0.082..49.059 rows=993703 loops=2) Index Cond: (logs_partioned_3.event = 'rewinded'::text) Heap Fetches: 876 Buffers: shared hit=1794 Worker 1: actual time=0.159..96.371 rows=1942980 loops=1 Buffers: shared hit=1755 -> Parallel Index Only Scan using logs_partioned_p1_event_idx on public.logs_partioned_p1 logs_partioned_1 (cost=0.44..22397.29 rows=619632 width=0) (actual time=0.025..95.237 rows=1965505 loops=1) Index Cond: (logs_partioned_1.event = 'rewinded'::text) Heap Fetches: 0 Buffers: shared hit=1689 -> Parallel Index Only Scan using logs_partioned_default_event_idx on public.logs_partioned_default logs_partioned_5 (cost=0.29..13.74 rows=543 width=0) (actual time=0.035..0.269 rows=923 loops=1) Index Cond: (logs_partioned_5.event = 'rewinded'::text) Heap Fetches: 0 Buffers: shared hit=4 Planning Time: 0.496 ms Execution Time: 250.672 ms Time: 251.689 ms ---- The specs and test setup: PostgreSQL 13.2 on arm-apple-darwin20.3.0, compiled by Apple clang version 12.0.0 (clang-1200.0.32.29), 64-bit Macbook Air M1 8GB RAM 8 core Settings: name | current_setting | source ----------------------------------+--------------------+---------------------- application_name | psql | client checkpoint_completion_target | 0.9 | configuration file checkpoint_timeout | 30min | configuration file client_encoding | UTF8 | client DateStyle | ISO, MDY | configuration file default_text_search_config | pg_catalog.english | configuration file dynamic_shared_memory_type | posix | configuration file effective_cache_size | 4GB | configuration file lc_messages | C | configuration file lc_monetary | C | configuration file lc_numeric | C | configuration file lc_time | C | configuration file log_directory | log | configuration file log_timezone | America/Anchorage | configuration file logging_collector | on | configuration file maintenance_work_mem | 1GB | configuration file max_connections | 8 | configuration file max_parallel_maintenance_workers | 2 | configuration file max_parallel_workers | 4 | configuration file max_parallel_workers_per_gather | 4 | configuration file max_stack_depth | 2MB | environment variable max_wal_size | 20GB | configuration file max_worker_processes | 4 | configuration file min_wal_size | 80MB | configuration file random_page_cost | 1.1 | configuration file shared_buffers | 2GB | configuration file TimeZone | America/Anchorage | configuration file vacuum_cost_limit | 2000 | configuration file wal_buffers | 64MB | configuration file wal_compression | on | configuration file work_mem | 256MB | configuration file -------------------- -- Queries: CREATE OR REPLACE FUNCTION random_event() RETURNS TEXT AS $$ DECLARE id int; events text[] := '{started,stopped,paused,closed,entered,rewinded,looped,skipped,ignored,playing,clicked,hovered,seeked,ignored,fastforwarded,repeated}'; BEGIN return events[1 + (random() * array_length(events, 1))]; END $$ LANGUAGE plpgsql; CREATE TABLE logs(created TIMESTAMPTZ DEFAULT now(), event TEXT); INSERT INTO logs SELECT generate_series, random_event() FROM generate_series('2020-01-01', '2021-01-01', interval '250 milliseconds'); VACUUM ANALYZE logs; CREATE INDEX ON logs(event); CREATE TABLE logs_partioned(created TIMESTAMPTZ DEFAULT now(), event TEXT) PARTITION BY RANGE(created); CREATE TABLE logs_partioned_p1 PARTITION OF logs_partioned FOR VALUES FROM ('2020-01-01') TO ('2020-04-01'); CREATE TABLE logs_partioned_p2 PARTITION OF logs_partioned FOR VALUES FROM ('2020-04-01') TO ('2020-07-01'); CREATE TABLE logs_partioned_p3 PARTITION OF logs_partioned FOR VALUES FROM ('2020-07-01') TO ('2020-10-01'); CREATE TABLE logs_partioned_p4 PARTITION OF logs_partioned FOR VALUES FROM ('2020-10-01') TO ('2021-01-01'); CREATE TABLE logs_partioned_default PARTITION OF logs_partioned DEFAULT; INSERT INTO logs_partioned SELECT * FROM logs; VACUUM ANALYZE logs_partioned; CREATE INDEX ON logs_partioned(event); --16dd1e6247954416a7de5995ef0ed3f5 Content-Type: text/html Content-Transfer-Encoding: quoted-printable
Hi there, my qu= estion is, shouldn't
a query that spans all partitions in = a partionend table be roughly the same in performance as one on
a non partionend table? I'm getting roughly 50% slower performance= on a partioned table.
I have tried this on a macbook and = ubuntu server. More details are below.

The queries:
EXP= LAIN (ANALYZE, VERBOSE, BUFFERS, COSTS) SELECT COUNT(*) FROM logs WHERE = event =3D 'rewinded';
= EXPLAIN (ANALYZE, VERBOSE, BUFFERS, COSTS) SELECT COUNT(*) FROM logs_par= tioned WHERE event =3D 'rewinded';

----
=
The results:

EXPLAIN (ANALYZE, V= ERBOSE, BUFFERS, COSTS) SELECT COUNT(*) FROM logs WHERE event =3D 'rewin= ded';
QUERY PLAN<= span class=3D"font" style=3D"font-family:menlo, consolas, monospace, san= s-serif;">
Finalize Aggregate  (cos= t=3D93673.28..93673.29 rows=3D1 width=3D8) (actual time=3D163.160..164.3= 21 rows=3D1 loops=3D1)
  Output: count(*)
  Buffers: shared hit=3D6929
<= div>  ->  Gather  (cost=3D93672.86..93673.2= 7 rows=3D4 width=3D8) (actual time=3D163.088..164.314 rows=3D4 loops=3D1= )
   &n= bsp;    Output: (PARTIAL count(*))
<= /span>
        W= orkers Planned: 4
&nbs= p;       Workers Launched: 3
      = ;  Buffers: shared hit=3D6929
        ->  Part= ial Aggregate  (cost=3D92672.86..92672.87 rows=3D1 width=3D8) (actu= al time=3D154.476..154.477 rows=3D1 loops=3D4)
        = ;      Output: PARTIAL count(*)      &= nbsp;       Buffers: shared hit=3D6929
    &= nbsp;         Worker 0:  ac= tual time=3D150.627..150.628 rows=3D1 loops=3D1
       &nbs= p;        Buffers: shared hit=3D1725<= /span>
   &nbs= p;          Worker 1: = actual time=3D152.368..152.368 rows=3D1 loops=3D1
=
       &= nbsp;        Buffers: shared hit=3D17= 18
   &= nbsp;          Worker 2:&nb= sp; actual time=3D152.219..152.220 rows=3D1 loops=3D1
       =          Buffers: shared hit=3D1= 727
   =            -> = Parallel Index Only Scan using logs_event_idx on public.logs  (cos= t=3D0.57..87681.79 rows=3D1996428 width=3D0) (actual time=3D0.101..90.80= 9 rows=3D1976526 loops=3D4)
           =          Output: event
     &= nbsp;           &= nbsp;  Index Cond: (logs.event =3D 'rewinded'::text)
      =             =   Heap Fetches: 854
           &nb= sp;        Buffers: shared hit=3D6929=
   &nb= sp;           &nb= sp;    Worker 0:  actual time=3D0.155..88.693 rows=3D= 1959750 loops=3D1
&nbs= p;           &nbs= p;         Buffers: shared hit=3D= 1725
   =             =      Worker 1:  actual time=3D0.106..89.503 row= s=3D1969110 loops=3D1
=             =           Buffers: shared h= it=3D1718
  =             =       Worker 2:  actual time=3D0.102..89.4= 30 rows=3D1973790 loops=3D1
           =            Buffers: sh= ared hit=3D1727
Planni= ng Time: 0.242 ms
Exec= ution Time: 164.383 ms
(30 rows)
Time: 165.1= 05 ms
-------
EXPLAIN (ANALYZE, VERBOSE, BUFFE= RS, COSTS) SELECT COUNT(*) FROM logs_partioned WHERE event =3D 'rewinded= ';
QUERY PLAN
Finalize Aggregate  (cost= =3D110643.80..110643.81 rows=3D1 width=3D8) (actual time=3D249.562..250.= 597 rows=3D1 loops=3D1)

  Buffers: shared hit=3D6889
<= div>  ->  Gather  (cost=3D110643.48..110643= .79 rows=3D3 width=3D8) (actual time=3D249.522..250.593 rows=3D4 loops=3D= 1)
   &= nbsp;    Output: (PARTIAL count(*))
=
        = Workers Planned: 3
&nb= sp;       Workers Launched: 3
     &nbs= p;  Buffers: shared hit=3D6889
        ->  Par= tial Aggregate  (cost=3D109643.48..109643.49 rows=3D1 width=3D8) (a= ctual time=3D240.213..240.214 rows=3D1 loops=3D4)
<= /span>
       &n= bsp;      Output: PARTIAL count(*)
     &nbs= p;        Buffers: shared hit=3D6889<= /span>
   &nbs= p;          Worker 0: = actual time=3D237.259..237.260 rows=3D1 loops=3D1
=
       &= nbsp;      Worker 0:  actual time=3D237.25= 9..237.260 rows=3D1 loops=3D1
          &nbs= p;     Buffers: shared hit=3D1678
       =        Worker 1:  actual time=3D237.2= 44..237.245 rows=3D1 loops=3D1
          &nb= sp;     Buffers: shared hit=3D1768=
      &nb= sp;       Worker 2:  actual time=3D23= 7.304..237.305 rows=3D1 loops=3D1
          =       Buffers: shared hit=3D1699
      =         ->  Parallel Append&n= bsp; (cost=3D0.44..103381.36 rows=3D2504849 width=3D0) (actual time=3D0.= 132..183.045 rows=3D1976526 loops=3D4)
<= div>         &nb= sp;          Buffers: share= d hit=3D6889
 &nb= sp;           &nb= sp;      Worker 0:  actual time=3D0.171..1= 79.435 rows=3D1951389 loops=3D1
<= span class=3D"font" style=3D"font-family:menlo, consolas, monospace, san= s-serif;">          &n= bsp;           Buffers= : shared hit=3D1678
&nb= sp;           &nb= sp;       Worker 1:  actual time=3D0.= 160..181.963 rows=3D1954680 loops=3D1
<= div>         &nb= sp;            Bu= ffers: shared hit=3D1768
           &nb= sp;        Worker 2:  actual tim= e=3D0.159..181.714 rows=3D1976309 loops=3D1
=
        &n= bsp;           &n= bsp; Buffers: shared hit=3D1699
<= span class=3D"font" style=3D"font-family:menlo, consolas, monospace, san= s-serif;">          &n= bsp;         ->  Paralle= l Index Only Scan using logs_partioned_p2_event_idx on public.logs_parti= oned_p2 logs_partioned_2  (cost=3D0.44..23064.91 rows=3D638123 widt= h=3D0) (actual time=3D0.129..47.947 rows=3D981544 loops=3D2)
     &nb= sp;           &nb= sp;        Index Cond: (logs_partione= d_2.event =3D 'rewinded'::text)
<= span class=3D"font" style=3D"font-family:menlo, consolas, monospace, san= s-serif;">          &n= bsp;           &n= bsp;   Heap Fetches: 0
=           &= nbsp;           &= nbsp;   Buffers: shared hit=3D1690
        &= nbsp;           &= nbsp;     Worker 0:  actual time=3D0.171..95.32= 2 rows=3D1951389 loops=3D1
           &= nbsp;           &= nbsp;    Buffers: shared hit=3D1678
=
       &= nbsp;           &= nbsp;      Worker 1:  actual time=3D0.087.= .0.571 rows=3D11700 loops=3D1
          &nbs= p;           &nbs= p;     Buffers: shared hit=3D12
       =             = ->  Parallel Index Only Scan using logs_partioned_p4_event_idx = on public.logs_partioned_p4 logs_partioned_4  (cost=3D0.44..22982.7= 5 rows=3D635850 width=3D0) (actual time=3D0.054..31.451 rows=3D663060 lo= ops=3D3)
  &= nbsp;           &= nbsp;           Index = Cond: (logs_partioned_4.event =3D 'rewinded'::text)
       =             =        Heap Fetches: 0
       =             =        Buffers: shared hit=3D1712
     =             =          Worker 1:  actual = time=3D0.001..0.001 rows=3D0 loops=3D1
<= div>         &nb= sp;           &nb= sp;      Buffers: shared hit=3D1
      =             =         Worker 2:  actual time=3D= 0.158..93.844 rows=3D1976309 loops=3D1
<= div>         &nb= sp;           &nb= sp;      Buffers: shared hit=3D1699
     &nb= sp;           &nb= sp;  ->  Parallel Index Only Scan using logs_partioned_p3_e= vent_idx on public.logs_partioned_p3 logs_partioned_3  (cost=3D0.44= ..22398.42 rows=3D610946 width=3D0) (actual time=3D0.082..49.059 rows=3D= 993703 loops=3D2)
&nbs= p;           &nbs= p;           &nbs= p; Index Cond: (logs_partioned_3.event =3D 'rewinded'::text)
     &nb= sp;           &nb= sp;        Heap Fetches: 876
     =             =          Buffers: shared hit=3D1= 794
   =             =            Worker 1:&n= bsp; actual time=3D0.159..96.371 rows=3D1942980 loops=3D1
      =             =           Buffers: shared h= it=3D1755
  =             =       ->  Parallel Index Only Scan usin= g logs_partioned_p1_event_idx on public.logs_partioned_p1 logs_partioned= _1  (cost=3D0.44..22397.29 rows=3D619632 width=3D0) (actual time=3D= 0.025..95.237 rows=3D1965505 loops=3D1)
         =             =      Index Cond: (logs_partioned_1.event =3D 'rewind= ed'::text)
  = ;            = ;            Heap= Fetches: 0
 &nbs= p;           &nbs= p;            Buf= fers: shared hit=3D1689
       =             =        Index Cond: (logs_partioned_5.event= =3D 'rewinded'::text)
            = ;            = ;  Heap Fetches: 0

= Planning Time: 0.496 ms
Execution Time: 250.672 ms
Time: 251.689 ms

-= ---

The specs and test setup:
PostgreSQL 13.2 on arm-apple-darwin20.3.0, compiled by Apple clang vers= ion 12.0.0 (clang-1200.0.32.29), 64-bit
Macbook Air M1 8GB= RAM 8 core

Settings:
           &n= bsp;   name        &nb= sp;      |  current_setting   |&= nbsp;       source
----------------------------------+--------------------+-------= ---------------
application_name &n= bsp;           &n= bsp;   | psql        &= nbsp;      | client
checkpoint_completion_target     | 0.9 &nb= sp;           &nb= sp;  | configuration file
checkpoin= t_timeout          &nb= sp;    | 30min       &= nbsp;      | configuration file
client_encoding      &nbs= p;           | UTF8&nb= sp;           &nb= sp;  | client
DateStyle  =             =           | ISO, MDY &= nbsp;         | configuration fi= le
default_text_search_config  = ;     | pg_catalog.english | configuration file
<= /span>
dynamic_shared_memory_type   =     | posix       &nbs= p;      | configuration file
effective_cache_size      &n= bsp;      | 4GB     &n= bsp;          | configurati= on file
lc_messages   &nb= sp;           &nb= sp;      | C      = ;            | co= nfiguration file
lc_monetary  =             =         | C    &n= bsp;           &n= bsp; | configuration file
lc_numeric&nbs= p;           &nbs= p;          | C  =             =     | configuration file
= lc_time           = ;            = ;   | C         &= nbsp;        | configuration file
=
log_directory     =             =    | log         =        | configuration file
log_timezone       =             =   | America/Anchorage  | configuration file
logging_collector       = ;         | on   =             =   | configuration file
maintenance_= work_mem          &nbs= p;  | 1GB         &nbs= p;      | configuration file
max_connections       &= nbsp;          | 8 &nb= sp;           &nb= sp;    | configuration file
max_parallel_maintenance_workers | 2     &nb= sp;            | = configuration file
max_parallel_workers&= nbsp;            = | 4           &nb= sp;      | configuration file
<= div>max_parallel_workers_per_gather  | 4  &nbs= p;           &nbs= p;   | configuration file
max_= stack_depth          &= nbsp;       | 2MB    &= nbsp;           | envi= ronment variable
max_wal_size  = ;            = ;       | 20GB    &nbs= p;          | configuration= file
max_worker_processes  &n= bsp;          | 4 &nbs= p;           &nbs= p;    | configuration file
random_pa= ge_cost           = ;      | 1.1      = ;          | configuration = file
shared_buffers   &nb= sp;           &nb= sp;   | 2GB        &nb= sp;       | configuration file
<= /div>
TimeZone       &= nbsp;           &= nbsp;     | America/Anchorage  | configuration = file
vacuum_cost_limit   =             = | 2000           = ;    | configuration file
wal_buffers          =             | 64M= B            = ;   | configuration file
wal_c= ompression          &n= bsp;       | on    &nb= sp;            | = configuration file
work_mem  &= nbsp;           &= nbsp;          | 256MB = ;            = ; | configuration file


--------------------
-- Queries:

CREATE OR REPLACE FUNCTION random_event() RETURNS TEXT AS
$$
DECLARE
  id int;
  events text[] :=3D '{started,stopped,paused,closed,entered,rewi= nded,looped,skipped,ignored,playing,clicked,hovered,seeked,ignored,fastf= orwarded,repeated}';
BEGIN
  return eve= nts[1 + (random() * array_length(events, 1))];
END
$$ LANGUAGE plpgsql;

CREATE TABLE lo= gs(created TIMESTAMPTZ DEFAULT now(), event TEXT);
INSERT = INTO logs SELECT generate_series, random_event() FROM generate_series('2= 020-01-01', '2021-01-01', interval '250 milliseconds');
VA= CUUM ANALYZE logs;
CREATE INDEX ON logs(event);
<= div>
CREATE TABLE logs_partioned(created TIMESTAMPTZ DEFAU= LT now(), event TEXT) PARTITION BY RANGE(created);
CREATE = TABLE logs_partioned_p1 PARTITION OF logs_partioned FOR VALUES FROM ('20= 20-01-01') TO ('2020-04-01');
CREATE TABLE logs_partioned_= p2 PARTITION OF logs_partioned FOR VALUES FROM ('2020-04-01') TO ('2020-= 07-01');
CREATE TABLE logs_partioned_p3 PARTITION OF logs_= partioned FOR VALUES FROM ('2020-07-01') TO ('2020-10-01');
CREATE TABLE logs_partioned_p4 PARTITION OF logs_partioned FOR VALUES = FROM ('2020-10-01') TO ('2021-01-01');
CREATE TABLE logs_p= artioned_default PARTITION OF logs_partioned DEFAULT;

=
INSERT INTO logs_partioned SELECT * FROM logs;
= VACUUM ANALYZE logs_partioned;
CREATE INDEX ON logs_partio= ned(event);

--16dd1e6247954416a7de5995ef0ed3f5--