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?.
INSERT 0 6
QUERY PLAN
Delete on test (cost=126.53..133.04 rows=325 width=132) (actual time=0.360..0.360 rows=0 loops=1)
  -> Merge Semi Join (cost=126.53..133.04 rows=325 width=132) (actual time=0.344..0.346 rows=3 loops=1)
        Merge Cond: (test.ctid = s.ctid)
        -> Sort (cost=46.87..48.49 rows=650 width=6) (actual time=0.060..0.061 rows=6 loops=1)
              Sort Key: test.ctid
              Sort Method: quicksort Memory: 25kB
              -> Seq Scan on test (cost=0.00..16.50 rows=650 width=6) (actual time=0.008..0.010 rows=6 loops=1)
        -> Sort (cost=79.67..80.21 rows=217 width=132) (actual time=0.279..0.279 rows=3 loops=1)
              Sort Key: s.ctid
              Sort Method: quicksort Memory: 25kB
              -> Subquery Scan on s (cost=46.87..71.24 rows=217 width=132) (actual time=0.200..0.212 rows=3 loops=1)
                    Filter: (s.row_number >= 2)
                    Rows Removed by Filter: 3
                    -> WindowAgg (cost=46.87..63.12 rows=650 width=110) (actual time=0.141..0.155 rows=6 loops=1)
                          -> Sort (cost=46.87..48.49 rows=650 width=102) (actual time=0.114..0.116 rows=6 loops=1)
                                Sort Key: test_1.col1, test_1.col2, test_1.col3, test_1.ctid
                                Sort Method: quicksort Memory: 25kB
                                -> Seq Scan on test test_1 (cost=0.00..16.50 rows=650 width=102) (actual time=0.006..0.007 rows=6 loops=1)
Planning time: 1.759 ms
Execution time: 0.942 ms
EXPLAIN
QUERY PLAN
Delete on test (cost=46.87..2786.87 rows=325 width=6) (actual time=0.055..0.055 rows=0 loops=1)
  -> Seq Scan on test (cost=46.87..2786.87 rows=325 width=6) (actual time=0.055..0.055 rows=0 loops=1)
        Filter: (NOT (SubPlan 1))
        Rows Removed by Filter: 3
        SubPlan 1
          -> Materialize (cost=46.87..54.74 rows=200 width=6) (actual time=0.014..0.015 rows=2 loops=3)
                -> Subquery Scan on s (cost=46.87..53.74 rows=200 width=6) (actual time=0.026..0.027 rows=3 loops=1)
                      -> Unique (cost=46.87..51.74 rows=200 width=102) (actual time=0.025..0.026 rows=3 loops=1)
                            -> Sort (cost=46.87..48.49 rows=650 width=102) (actual time=0.025..0.025 rows=3 loops=1)
                                  Sort Key: test_1.col1, test_1.col2
                                  Sort Method: quicksort Memory: 25kB
                                  -> Seq Scan on test test_1 (cost=0.00..16.50 rows=650 width=102) (actual time=0.005..0.006 rows=3 loops=1)
Planning time: 0.075 ms
Execution time: 0.125 ms
EXPLAIN
ctid
SELECT 0
QUERY PLAN
Delete on test ju (cost=12927.43..12932.88 rows=147 width=132) (actual time=0.168..0.168 rows=0 loops=1)
  -> Merge Semi Join (cost=12927.43..12932.88 rows=147 width=132) (actual time=0.167..0.167 rows=0 loops=1)
        Merge Cond: (ju.ctid = s.ctid)
        -> Sort (cost=46.87..48.49 rows=650 width=6) (actual time=0.065..0.065 rows=1 loops=1)
              Sort Key: ju.ctid
              Sort Method: quicksort Memory: 25kB
              -> Seq Scan on test ju (cost=0.00..16.50 rows=650 width=6) (actual time=0.006..0.007 rows=3 loops=1)
        -> Sort (cost=12880.56..12880.93 rows=147 width=132) (actual time=0.100..0.100 rows=0 loops=1)
              Sort Key: s.ctid
              Sort Method: quicksort Memory: 25kB
              -> Subquery Scan on s (cost=12872.17..12875.27 rows=147 width=132) (actual time=0.067..0.067 rows=0 loops=1)
                    -> Unique (cost=12872.17..12873.80 rows=147 width=102) (actual time=0.066..0.066 rows=0 loops=1)
                          -> Sort (cost=12872.17..12872.71 rows=217 width=102) (actual time=0.066..0.066 rows=0 loops=1)
                                Sort Key: ou.col1, ou.col2
                                Sort Method: quicksort Memory: 25kB
                                -> Seq Scan on test ou (cost=0.00..12863.75 rows=217 width=102) (actual time=0.028..0.028 rows=0 loops=1)
                                      Filter: ((SubPlan 1) > 1)
                                      Rows Removed by Filter: 3
                                      SubPlan 1
                                        -> Aggregate (cost=19.75..19.76 rows=1 width=8) (actual time=0.004..0.004 rows=1 loops=3)
                                              -> Seq Scan on test inr (cost=0.00..19.75 rows=1 width=0) (actual time=0.002..0.002 rows=1 loops=3)
                                                    Filter: ((col1 = ou.col1) AND (col2 = ou.col2))
                                                    Rows Removed by Filter: 2
Planning time: 0.145 ms
Execution time: 0.339 ms
EXPLAIN
QUERY PLAN
Delete on test a (cost=93.74..106.75 rows=1 width=12) (actual time=0.142..0.142 rows=0 loops=1)
  -> Merge Join (cost=93.74..106.75 rows=1 width=12) (actual time=0.141..0.141 rows=0 loops=1)
        Merge Cond: ((a.col1 = b.col1) AND (a.col2 = b.col2) AND (a.col3 = b.col3))
        Join Filter: (a.ctid < b.ctid)
        Rows Removed by Join Filter: 3
        -> Sort (cost=46.87..48.49 rows=650 width=102) (actual time=0.063..0.063 rows=3 loops=1)
              Sort Key: a.col1, a.col2, a.col3
              Sort Method: quicksort Memory: 25kB
              -> Seq Scan on test a (cost=0.00..16.50 rows=650 width=102) (actual time=0.007..0.009 rows=3 loops=1)
        -> Sort (cost=46.87..48.49 rows=650 width=102) (actual time=0.071..0.072 rows=3 loops=1)
              Sort Key: b.col1, b.col2, b.col3
              Sort Method: quicksort Memory: 25kB
              -> Seq Scan on test b (cost=0.00..16.50 rows=650 width=102) (actual time=0.005..0.007 rows=3 loops=1)
Planning time: 0.108 ms
Execution time: 0.262 ms
EXPLAIN