Skip to content

Commit

Permalink
use a subselect instead of a CTE when building incremental models (#787)
Browse files Browse the repository at this point in the history
(must faster on postgresql due to the CTE optimization fence)
  • Loading branch information
drewbanin authored Jun 8, 2018
1 parent c19a426 commit fa43d9d
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@
{%- call statement() -%}

{% set tmp_table_sql -%}
with dbt_incr_sbq as (
{{ sql }}
)
select * from dbt_incr_sbq
{# We are using a subselect instead of a CTE here to allow PostgreSQL to use indexes. -#}
select * from ({{ sql }}) as dbt_incr_sbq
where ({{ sql_where }})
or ({{ sql_where }}) is null
{%- endset %}
Expand Down

0 comments on commit fa43d9d

Please sign in to comment.