-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slow performance when materialization as table (SELECT * INTO Model__dbt_tmp FROM Model__dbt_tmp_temp_view
)
#410
Comments
For what it’s worth, nested views perform horribly in SQL Server because of how the query planner works. That being said, I really like the idea of supporting query hints as config in the macros. |
Came in here from google. We're experiencing the same issue, dreadfully slow performance in dbt, We're on sql server 2019 and dbt 1.4.6 (since dbt-sqlserver isn't 1.5 yet). adding
|
Here, I've experienced some models with slow performance without For them, I created a config at model code, and had created a copy of macro At my job, our SQL Server is not exclusive to our DW. I've about a dozen of other DBs used by other workloads (in general OLTP, but also have a couple of DBs for OLAP, where our users connect their Excel's at SQL tables and analyze data with Pivot Table). So, I've moments during the workday, where In general, without bottlenecks in SQL Server, a |
@romiof we just patched sqlserver__create_table_as in a larger dbt project (adding option (force order)) and model performance time greatly improved, from around 900 seconds down to 30. |
Now we have a bit more experience with
then in the table config we can turn it off where needed:
|
Hello!
This is a bug and a suggestion for improvement...
I'm suffering with slow performance when materialization as table.
My environment
I started this month to use dbt for MS SQL. My database is a SQL Server 2014. Using the last version of dbt
1.4.3
My issue
I'm having problems whit materialization macro which make the tables at our SQL Server. Its performance is very, very slow.
More specific, my project consist in:
yml files
, to map my tables to dbt objectstables
dbt run / dbt build
it performs very poor.What I investigated
_Model__dbt_tmp_temp_view_
is a nested view, and this is the origin of my problem.SELECT * FROM _Model__dbt_tmp_temp_view_
, everything works fine, the performance is equal when I select without the temp view.INTO Model__dbt_tmp
(https://github.com/dbt-msft/dbt-sqlserver/blob/master/dbt/include/sqlserver/macros/materializations/models/table/create_table_as.sql#LL23-L25) my SQL change its plan and it takes about 10 minutes to execute this materialization.SELECT * FROM _Model__dbt_tmp_temp_view_
vsSELECT * INTO Model__dbt_tmp FROM _Model__dbt_tmp_temp_view_
)A possible workaround
I also discovered, that there is a hint which make
SELECT * INTO Model__dbt_tmp FROM _Model__dbt_tmp_temp_view_
runs with its original perfomance:OPTION (FORCE ORDER)
I founded it from this SO post.
So, if I run this query
SELECT * INTO Model__dbt_tmp FROM _Model__dbt_tmp_temp_view_ OPTION (FORCE ORDER)
from my MS SQL Studio, it create my Model table in less than 1 minute.Setting this option at dbt-sqlserver
I'd like to know, how can we change this macro to have a possibility to include this hint ?
Maybe a configuration, like
as_columnstore
?The text was updated successfully, but these errors were encountered: