@@ -449,14 +449,9 @@ exec-ddl
449449DROP INDEX partial_idx
450450----
451451
452- # NOTE: A placeholder scan is generated but not chosen because the cost is
453- # higher than the lookup-join, due to the conservative row count estimate of 330
454- # for the group with the inner project (which is the group that the placeholder
455- # scan is added to).
456- #
457- # TODO(mgartner): Tighten the row count estimate of 330. By default there are
458- # 1000 rows and 100 distinct values for t, so the row count should be ~10.
459- opt no-stable-folds expect=(GenerateParameterizedJoin,ConvertParameterizedLookupJoinToPlaceholderScan) format=(show-stats,show-cost)
452+ # A placeholder scan's scalars values contain only constants or placeholders.
453+ # Stable functions are not supported at execbuild-time.
454+ opt no-stable-folds expect=(GenerateParameterizedJoin) expect-not=(ConvertParameterizedLookupJoinToPlaceholderScan) format=(show-stats,show-cost)
460455SELECT k FROM t WHERE t = now()
461456----
462457project
@@ -536,14 +531,27 @@ project
536531 ├── columns: k:1!null
537532 ├── stable, has-placeholder
538533 ├── key: (1)
539- └── placeholder-scan t@t_i_t_idx
534+ └── project
540535 ├── columns: k:1!null i:2!null t:5!null
541536 ├── stable, has-placeholder
542537 ├── key: (1)
543538 ├── fd: ()-->(2,5)
544- └── span
545- ├── $1
546- └── now()
539+ └── inner-join (lookup t@t_i_t_idx)
540+ ├── columns: k:1!null i:2!null t:5!null "$1":8!null column9:9!null
541+ ├── flags: disallow merge join
542+ ├── key columns: [8 9] = [2 5]
543+ ├── parameterized columns: (8,9)
544+ ├── stable, has-placeholder
545+ ├── key: (1)
546+ ├── fd: ()-->(2,5,8,9), (2)==(8), (8)==(2), (5)==(9), (9)==(5)
547+ ├── values
548+ │ ├── columns: "$1":8 column9:9
549+ │ ├── cardinality: [1 - 1]
550+ │ ├── stable, has-placeholder
551+ │ ├── key: ()
552+ │ ├── fd: ()-->(8,9)
553+ │ └── ($1, now())
554+ └── filters (true)
547555
548556opt no-stable-folds expect=GenerateParameterizedJoin
549557SELECT * FROM t WHERE i = $1 AND t = now()
@@ -846,17 +854,33 @@ placeholder-scan t
846854 └── span
847855 └── $1
848856
849- opt no-stable-folds expect=ConvertParameterizedLookupJoinToPlaceholderScan
857+ # A placeholder scan's scalars values contain only constants or placeholders.
858+ # Stable functions are not supported at execbuild-time.
859+ opt no-stable-folds expect-not=ConvertParameterizedLookupJoinToPlaceholderScan
850860SELECT t.k FROM (VALUES (quote_literal(1)::INT)) AS v(k) JOIN t ON t.k = v.k
851861----
852- placeholder-scan t
862+ project
853863 ├── columns: k:2!null
854864 ├── cardinality: [0 - 1]
855865 ├── stable
856866 ├── key: ()
857867 ├── fd: ()-->(2)
858- └── span
859- └── quote_literal(1)::INT8
868+ └── inner-join (lookup t)
869+ ├── columns: column1:1!null k:2!null
870+ ├── key columns: [1] = [2]
871+ ├── lookup columns are key
872+ ├── cardinality: [0 - 1]
873+ ├── stable
874+ ├── key: ()
875+ ├── fd: ()-->(1,2), (1)==(2), (2)==(1)
876+ ├── values
877+ │ ├── columns: column1:1
878+ │ ├── cardinality: [1 - 1]
879+ │ ├── stable
880+ │ ├── key: ()
881+ │ ├── fd: ()-->(1)
882+ │ └── (quote_literal(1)::INT8,)
883+ └── filters (true)
860884
861885# The rule does not match if there are no placeholders or stable expressions in
862886# the Values expression.
0 commit comments