pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
inner join elimination
2+ messages / 2 participants
[nested] [flat]

* inner join elimination
@ 2018-05-29 08:30 Arturo Guadagnin <tuirutuiru@gmail.com>
  2018-06-07 21:44 ` Re: inner join elimination pinker <pinker@onet.eu>
  0 siblings, 1 reply; 2+ messages in thread

From: Arturo Guadagnin @ 2018-05-29 08:30 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>


Hi

I was just wondering whether inner join elimination is working in postgres, so I put up a simple test case and compared it with an Oracle database (see output below).
It doesn't look like this feature is implemented in postgres, or am I missig something?
Are there any plans to implement it in the future?

-----------------------------------------
* Oracle 11.2
----------------------------------------

CREATE TABLE m ( 
   i INTEGER NOT NULL,
   c VARCHAR(10),
   CONSTRAINT m_pk PRIMARY KEY(i)
);


CREATE TABLE c ( 
   i INTEGER NOT NULL,
   created_tm DATE NOT NULL,
   CONSTRAINT c_pk PRIMARY KEY(i, created_tm),
   CONSTRAINT c_m_fk FOREIGN KEY(i) REFERENCES m
);

explain plan for    
select c.*
from m
  join c
    ON (m.i = c.i);    
    
select *
from table(dbms_xplan.display);    

--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |     1 |    22 |     2   (0)| 00:00:01 |
|   1 |  TABLE ACCESS FULL| C    |     1 |    22 |     2   (0)| 00:00:01 |
--------------------------------------------------------------------------

----------------------------------------
* postgres 11-beta
----------------------------------------

CREATE TABLE m ( 
   i INTEGER NOT NULL,
   c VARCHAR(10),
   CONSTRAINT m_pk PRIMARY KEY(i)
);


CREATE TABLE c ( 
   i INTEGER NOT NULL,
   created_tm timestamp NOT NULL,
   CONSTRAINT c_pk PRIMARY KEY(i, created_tm),
   CONSTRAINT c_m_fk FOREIGN KEY(i) REFERENCES m
);


explain  
select c.*
from m
  join c
    ON (m.i = c.i);    
    
                           QUERY PLAN                            
-----------------------------------------------------------------
Hash Join  (cost=36.10..92.24 rows=2040 width=12)
   Hash Cond: (c.i = m.i)
   ->  Seq Scan on c  (cost=0.00..30.40 rows=2040 width=12)
   ->  Hash  (cost=21.60..21.60 rows=1160 width=4)
         ->  Seq Scan on m  (cost=0.00..21.60 rows=1160 width=4)

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: inner join elimination
  2018-05-29 08:30 inner join elimination Arturo Guadagnin <tuirutuiru@gmail.com>
@ 2018-06-07 21:44 ` pinker <pinker@onet.eu>
  0 siblings, 0 replies; 2+ messages in thread

From: pinker @ 2018-06-07 21:44 UTC (permalink / raw)
  To: pgsql-general

As far as I know PostgreSQL does only OUTER JOIN Elimination, with inner join
it doesn't work.



--
Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2018-06-07 21:44 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-05-29 08:30 inner join elimination Arturo Guadagnin <tuirutuiru@gmail.com>
2018-06-07 21:44 ` pinker <pinker@onet.eu>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox