0
CREATE TABLE a (aid int);
CREATE TABLE b (bid int);
INSERT INTO a VALUES (1), (2), (3);
INSERT INTO b VALUES (2), (3), (4);

What would be the difference between

SELECT * FROM a, b WHERE aid = bid; and

SELECT * FROM a JOIN b ON a.aid=b.bid;

The result of explain analyze for both queries looks totally same.

Kir
  • 7,981
  • 12
  • 52
  • 69
  • 2
    Use only `JOIN` syntax. Comma syntax is old and obsolete. With outer join you need to use error prone `*=` or `=*` operators. – Lukasz Szozda Nov 07 '15 at 12:33
  • @lad2025: There is not such operator `*=` or `=*` in (standard) SQL and definitely not in Postgres. –  Nov 07 '15 at 12:57
  • @a_horse_with_no_name `(+)=` or `*=` are Oracle/SQL Server specific. But it doesn't change the fact that the comma syntax join is obsolete and should be avoided. – Lukasz Szozda Nov 07 '15 at 13:08

1 Answers1

-1

Both queries do exactly the same.

  • I suspect you'll find the execution plan for both queries is identical – Hambone Nov 07 '15 at 12:55
  • 1
    The JOIN is not "more efficient" - they are exactly the same. Neither one is "more efficient" than the other –  Nov 07 '15 at 12:56