Giter Club home page Giter Club logo

Comments (2)

dhanashreek89 avatar dhanashreek89 commented on July 18, 2024

AFAIK ORCA does not generate initplans. If we insert some data into these relations or increase the number of segments, then ORCA does pick a plan with nestloop join

Insert Data

insert into foo values(1), (2);
insert into bar select i from generate_series(1,1000)i;
analyze;

explain select * from foo where a >= (select avg(b) from bar);
                                        QUERY PLAN
------------------------------------------------------------------------------------------
 Nested Loop  (cost=0.00..1324042.42 rows=1 width=8)
   Join Filter: foo.a::numeric >= (pg_catalog.avg((avg(bar.b))))
   ->  Aggregate  (cost=0.00..431.01 rows=1 width=8)
         ->  Gather Motion 3:1  (slice2; segments: 3)  (cost=0.00..431.01 rows=1 width=8)
               ->  Aggregate  (cost=0.00..431.01 rows=1 width=8)
                     ->  Table Scan on bar  (cost=0.00..431.01 rows=334 width=4)
   ->  Materialize  (cost=0.00..431.00 rows=1 width=8)
         ->  Gather Motion 3:1  (slice1; segments: 3)  (cost=0.00..431.00 rows=2 width=8)
               ->  Table Scan on foo  (cost=0.00..431.00 rows=1 width=8)
 Settings:  optimizer=on
 Optimizer status: PQO version 2.54.2
(11 rows)

Increase number of segmnets

truncate foo, bar;
set optimizer_segments=40;

explain select * from foo where a >= (select avg(b) from bar);
                                                 QUERY PLAN
------------------------------------------------------------------------------------------------------------
 Gather Motion 3:1  (slice4; segments: 3)  (cost=0.00..1324033.11 rows=1 width=8)
   ->  Nested Loop  (cost=0.00..1324033.11 rows=1 width=8)
         Join Filter: foo.a::numeric >= (pg_catalog.avg((avg(bar.b))))
         ->  Broadcast Motion 3:3  (slice3; segments: 3)  (cost=0.00..431.00 rows=14 width=8)
               ->  Table Scan on foo  (cost=0.00..431.00 rows=1 width=8)
         ->  Materialize  (cost=0.00..431.00 rows=1 width=8)
               ->  Redistribute Motion 1:3  (slice2)  (cost=0.00..431.00 rows=1 width=8)
                     ->  Aggregate  (cost=0.00..431.00 rows=1 width=8)
                           ->  Gather Motion 3:1  (slice1; segments: 3)  (cost=0.00..431.00 rows=1 width=8)
                                 ->  Aggregate  (cost=0.00..431.00 rows=1 width=8)
                                       ->  Table Scan on bar  (cost=0.00..431.00 rows=1 width=4)
 Settings:  optimizer=on; optimizer_segments=40
 Optimizer status: PQO version 2.54.2
(13 rows)

from gporca.

hsyuan avatar hsyuan commented on July 18, 2024

But even with some data, it can still generate the subplan.

from gporca.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.