Home > Net >  What does Unique mean in EXPLAIN ANALYZE Postgresql
What does Unique mean in EXPLAIN ANALYZE Postgresql

Time:01-28

I ran EXPLAIN ANALYZE of the query:

INSERT INTO "Person"
SELECT DISTINCT undergraduateDegreeFrom_0.a, 3
FROM "undergraduateDegreeFrom" undergraduateDegreeFrom_0
WHERE undergraduateDegreeFrom_0.flag = 2
  AND NOT EXISTS (SELECT * FROM "Person" Person_NotExists
                  WHERE undergraduateDegreeFrom_0.a = Person_NotExists._0);

and received the following access plan: Access Plan Access Plan

#   Node    Rows    Loops

Actual

  1. Insert on Person as Person (rows=0 loops=1) 0 1
  2. Unique (rows=2414 loops=1) 2414 1
  3. Sort (rows=2414 loops=1) 2414 1
  4. Seq Scan on undergraduateDegreeFrom as undergraduatedegreefrom_0 (rows=2414 loops=1) Filter: (flag = 2) Rows Removed by Filter: 0 2414 1

I was wondering what the Unique part (on line 2) meant? Any help would be much appreciated.

(I tried running the EXPLAIN ANALYZE and was confused about what the Unique part meant)

CodePudding user response:

I think it is your distinct statement, which is referenced here. So, the database fulfills your distinct requirement here.

To verify this hypothesis you could run the same explain analyze while omitting the distinct clause.

  • Related