add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
word_permutations
ABCD
A BCD
AB CD
A B CD
ABC D
A BC D
AB C D
A B C D
perm
ABCD
ABC D
AB CD
AB C D
A BCD
A BC D
A B CD
A B C D
QUERY PLAN
ProjectSet (cost=0.00..5.27 rows=1000 width=32) (actual rows=32768 loops=1)
  -> Result (cost=0.00..0.01 rows=1 width=0) (actual rows=1 loops=1)
Planning Time: 0.011 ms
Execution Time: 23.939 ms
QUERY PLAN
CTE Scan on cte (cost=10.23..14.30 rows=1 width=32) (actual rows=32768 loops=1)
  Filter: (rest = ''::text)
  Rows Removed by Filter: 32767
  CTE cte
    -> Recursive Union (cost=0.00..10.23 rows=181 width=64) (actual rows=65535 loops=1)
          -> Result (cost=0.00..0.01 rows=1 width=64) (actual rows=1 loops=1)
          -> Nested Loop (cost=0.00..0.66 rows=18 width=64) (actual rows=4096 loops=16)
                -> WorkTable Scan on cte cte_1 (cost=0.00..0.22 rows=9 width=64) (actual rows=2048 loops=16)
                      Filter: (rest <> ''::text)
                      Rows Removed by Filter: 2048
                -> Materialize (cost=0.00..0.04 rows=2 width=32) (actual rows=2 loops=32767)
                      -> Values Scan on "*VALUES*" (cost=0.00..0.03 rows=2 width=32) (actual rows=2 loops=1)
Planning Time: 0.152 ms
Execution Time: 56.211 ms
QUERY PLAN
HashAggregate (cost=23347.35..23350.35 rows=200 width=72) (actual rows=32768 loops=1)
  Group Key: 'ABCDEFGHIJKLMNOP'::text, i.i
  Batches: 33 Memory Usage: 3529kB Disk Usage: 28152kB
  -> Nested Loop (cost=0.01..9830.55 rows=491520 width=44) (actual rows=491520 loops=1)
        -> Function Scan on generate_series p (cost=0.00..0.15 rows=15 width=4) (actual rows=15 loops=1)
        -> Function Scan on generate_series i (cost=0.00..327.68 rows=32768 width=8) (actual rows=32768 loops=15)
Planning Time: 0.260 ms
Execution Time: 1126.010 ms
QUERY PLAN
Nested Loop (cost=0.53..18677.76 rows=32768 width=32) (actual rows=32768 loops=1)
  -> Function Scan on generate_series i (cost=0.00..327.68 rows=32768 width=8) (actual rows=32768 loops=1)
  -> Aggregate (cost=0.52..0.54 rows=1 width=32) (actual rows=1 loops=32768)
        -> Function Scan on generate_series g (cost=0.00..0.16 rows=16 width=4) (actual rows=16 loops=32768)
Planning Time: 0.150 ms
Execution Time: 453.432 ms
words
ABCD
A BCD
AB CD
A B CD
ABC D
A BC D
AB C D
A B C D
words
ABCD
A BCD
AB CD
A B CD
ABC D
A BC D
AB C D
A B C D
words
ABCD
AB CD
A BCD
A B CD
ABC D
AB C D
A BC D
A B C D
QUERY PLAN
Nested Loop (cost=0.03..3564.08 rows=32768 width=32) (actual rows=32768 loops=1)
  CTE sep
    -> Values Scan on "*VALUES*" (cost=0.00..0.03 rows=2 width=32) (actual rows=2 loops=1)
  -> Nested Loop (cost=0.00..451.07 rows=16384 width=448) (actual rows=16384 loops=1)
        -> CTE Scan on sep sep2 (cost=0.00..0.04 rows=2 width=32) (actual rows=2 loops=1)
        -> Materialize (cost=0.00..266.71 rows=8192 width=416) (actual rows=8192 loops=2)
              -> Nested Loop (cost=0.00..225.75 rows=8192 width=416) (actual rows=8192 loops=1)
                    -> CTE Scan on sep sep8 (cost=0.00..0.04 rows=2 width=32) (actual rows=2 loops=1)
                    -> Materialize (cost=0.00..133.55 rows=4096 width=384) (actual rows=4096 loops=2)
                          -> Nested Loop (cost=0.00..113.07 rows=4096 width=384) (actual rows=4096 loops=1)
                                -> CTE Scan on sep sep12 (cost=0.00..0.04 rows=2 width=32) (actual rows=2 loops=1)
                                -> Materialize (cost=0.00..66.95 rows=2048 width=352) (actual rows=2048 loops=2)
                                      -> Nested Loop (cost=0.00..56.71 rows=2048 width=352) (actual rows=2048 loops=1)
                                            -> CTE Scan on sep sep6 (cost=0.00..0.04 rows=2 width=32) (actual rows=2 loops=1)
                                            -> Materialize (cost=0.00..33.63 rows=1024 width=320) (actual rows=1024 loops=2)
                                                  -> Nested Loop (cost=0.00..28.51 rows=1024 width=320) (actual rows=1024 loops=1)
                                                        -> CTE Scan on sep sep1 (cost=0.00..0.04 rows=2 width=32) (actual rows=2 loops=1)
                                                        -> Materialize (cost=0.00..16.95 rows=512 width=288) (actual rows=512 loops=2)
                                                              -> Nested Loop (cost=0.00..14.39 rows=512 width=288) (actual rows=512 loops=1)
                                                                    -> CTE Scan on sep sep9 (cost=0.00..0.04 rows=2 width=32) (actual rows=2 loops=1)
                                                                    -> Materialize (cost=0.00..8.59 rows=256 width=256) (actual rows=256 loops=2)
                                                                          -> Nested Loop (cost=0.00..7.31 rows=256 width=256) (actual rows=256 loops=1)
                                                                                -> CTE Scan on sep sep10 (cost=0.00..0.04 rows=2 width=32) (actual rows=2 loops=1)
                                                                                -> Materialize (cost=0.00..4.39 rows=128 width=224) (actual rows=128 loops=2)
                                                                                      -> Nested Loop (cost=0.00..3.75 rows=128 width=224) (actual rows=128 loops=1)
                                                                                            -> CTE Scan on sep sep15 (cost=0.00..0.04 rows=2 width=32) (actual rows=2 loops=1)
                                                                                            -> Materialize (cost=0.00..2.27 rows=64 width=192) (actual rows=64 loops=2)
                                                                                                  -> Nested Loop (cost=0.00..1.95 rows=64 width=192) (actual rows=64 loops=1)
                                                                                                        -> CTE Scan on sep sep4 (cost=0.00..0.04 rows=2 width=32) (actual rows=2 loops=1)
                                                                                                        -> Materialize (cost=0.00..1.19 rows=32 width=160) (actual rows=32 loops=2)
                                                                                                              -> Nested Loop (cost=0.00..1.03 rows=32 width=160) (actual rows=32 loops=1)
                                                                                                                    -> CTE Scan on sep sep5 (cost=0.00..0.04 rows=2 width=32) (actual rows=2 loops=1)
                                                                                                                    -> Materialize (cost=0.00..0.63 rows=16 width=128) (actual rows=16 loops=2)
                                                                                                                          -> Nested Loop (cost=0.00..0.55 rows=16 width=128) (actual rows=16 loops=1)
                                                                                                                                -> CTE Scan on sep sep7 (cost=0.00..0.04 rows=2 width=32) (actual rows=2 loops=1)
                                                                                                                                -> Materialize (cost=0.00..0.33 rows=8 width=96) (actual rows=8 loops=2)
                                                                                                                                      -> Nested Loop (cost=0.00..0.29 rows=8 width=96) (actual rows=8 loops=1)
                                                                                                                                            -> CTE Scan on sep sep11 (cost=0.00..0.04 rows=2 width=32) (actual rows=2 loops=1)
                                                                                                                                            -> Materialize (cost=0.00..0.16 rows=4 width=64) (actual rows=4 loops=2)
                                                                                                                                                  -> Nested Loop (cost=0.00..0.14 rows=4 width=64) (actual rows=4 loops=1)
                                                                                                                                                        -> CTE Scan on sep sep14 (cost=0.00..0.04 rows=2 width=32) (actual rows=2 loops=1)
                                                                                                                                                        -> CTE Scan on sep sep3 (cost=0.00..0.04 rows=2 width=32) (actual rows=2 loops=2)
  -> CTE Scan on sep sep13 (cost=0.00..0.04 rows=2 width=32) (actual rows=2 loops=16384)
Planning Time: 9.936 ms
Execution Time: 56.137 ms
word_permutations_yper
ABCD
AB CD
A BCD
A B CD
ABC D
AB C D
A BC D
A B C D
QUERY PLAN
ProjectSet (cost=0.00..5.27 rows=1000 width=32) (actual rows=32768 loops=1)
  -> Result (cost=0.00..0.01 rows=1 width=0) (actual rows=1 loops=1)
Planning Time: 0.012 ms
Execution Time: 9.486 ms