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.
version()
8.0.22
id contact_id contact_name
1 1 John Doe
2 2 Mary Smith
3 3 Jose Garcia
4 4 Larry Brown
id pri_contact_id sec_contact_id blah_blah
1 1 3 Team A
3 1 null Team A
2 4 2 Team B
id contact_id contact_name pri_contact_id sec_contact_id blah_blah
1 1 John Doe 1 3 Team A
1 1 John Doe 1 null Team A
4 4 Larry Brown 4 2 Team B
id contact_id contact_name id contact_id contact_name pri_contact_id sec_contact_id blah_blah
1 1 John Doe 3 3 Jose Garcia 1 3 Team A
4 4 Larry Brown 2 2 Mary Smith 4 2 Team B
Con_1 name Con_2 name Team
John Doe Jose Garcia Team A
Larry Brown Mary Smith Team B
Con_1 name Con_2 name Team
John Doe Jose Garcia Team A
John Doe null Team A
Larry Brown Mary Smith Team B
EXPLAIN
-> Sort: nl1.id (actual time=0.078..0.078 rows=2 loops=1)
    -> Stream results (cost=3.45 rows=3) (actual time=0.058..0.063 rows=2 loops=1)
        -> Inner hash join (nl2.contact_id = ci1.sec_contact_id) (cost=3.45 rows=3) (actual time=0.056..0.059 rows=2 loops=1)
            -> Table scan on nl2 (cost=0.12 rows=4) (actual time=0.005..0.008 rows=4 loops=1)
            -> Hash
                -> Inner hash join (nl1.contact_id = ci1.pri_contact_id) (cost=2.00 rows=3) (actual time=0.036..0.040 rows=3 loops=1)
                    -> Table scan on nl1 (cost=0.12 rows=4) (actual time=0.006..0.007 rows=4 loops=1)
                    -> Hash
                        -> Table scan on ci1 (cost=0.55 rows=3) (actual time=0.015..0.018 rows=3 loops=1)
EXPLAIN
-> Sort: nl1.id, ci1.blah_blah (actual time=0.072..0.072 rows=3 loops=1)
    -> Stream results (cost=5.11 rows=48) (actual time=0.053..0.060 rows=3 loops=1)
        -> Left hash join (nl2.contact_id = ci1.sec_contact_id) (cost=5.11 rows=48) (actual time=0.050..0.056 rows=3 loops=1)
            -> Left hash join (nl1.contact_id = ci1.pri_contact_id) (cost=1.67 rows=12) (actual time=0.021..0.025 rows=3 loops=1)
                -> Table scan on ci1 (cost=0.55 rows=3) (actual time=0.005..0.007 rows=3 loops=1)
                -> Hash
                    -> Table scan on nl1 (cost=0.22 rows=4) (actual time=0.005..0.007 rows=4 loops=1)
            -> Hash
                -> Table scan on nl2 (cost=0.05 rows=4) (actual time=0.015..0.018 rows=4 loops=1)