简体   繁体   English

我可以提高 excel 到 sql powerquery 的性能吗? 我正在使用命名范围参数而不是单元格值?

[英]Can I improve excel to sql powerquery performance? I'm using named range parameters instead of cell values?

This is my first post so I hope I get my question across OK.这是我的第一篇文章,所以我希望我的问题能通过 OK 解决。

I have designed a product configurator app in excel.我在 excel 中设计了一个产品配置器应用程序。 Using a series of drop down menus and user forms I can build a basic front elevation of what my product will look like whilst also deriving a list of sub assembly names that will make up the product.使用一系列下拉菜单和用户表单,我可以构建我的产品外观的基本正面图,同时还导出将构成产品的子组件名称列表。 This sub assembly list can be viewed on a hidden worksheet.可以在隐藏的工作表上查看此子装配列表。 There could be over 200 of these required to make up the product.组成产品可能需要 200 多个这些。

(eg My product could be made up of up to 16 Sections. Each Section could have 15 different sub assemblies. So my full product could have a combination of ~240 different sub assemblies, depending on the specific requirements.) (例如,我的产品最多可以由 16 个部分组成。每个部分可以有 15 个不同的子组件。所以我的完整产品可以有大约 240 个不同子组件的组合,具体取决于具体要求。)

I have named cells on the sub assembly worksheet where the sub assembly is stored.我在存储子组件的子组件工作表上命名了单元格。 This sub assembly name is dynamic depending on selections in the configurator.此子程序集名称是动态的,具体取决于配置器中的选择。

(eg Cell name - ARE_Section01 Dynamic sub assembly name in cell - AU_ARE_36_36_GA11_AL3_X_13_3__ANSI_61_ or AU_ARE_22_36_GA11_GA11_R_13_3__ANSI_61_ or AU_ARE_22_36_GA11_GA11_X_13_3__ANSI_61_ or etc.) (例如,单元名称 - ARE_Section01 单元中的动态子组件名称 - AU_ARE_36_36_GA11_AL3_X_13_3__ANSI_61_ 或 AU_ARE_22_36_GA11_GA11_R_13_3__ANSI_61_ 或 AU_ARE_22_31_GA11_或 AU_ARE_22_31_GA11_1_GA3_1_3_1_1_1_GA3_1_3_1_1_1_63

示例图像

In order to build a top level bill of materials I am pulling information from an SQL Server where there is a table for every possible sub assembly (over 700 of them).为了构建顶级材料清单,我从 SQL Server 中提取信息,其中每个可能的子组件(其中超过 700 个)都有一个表。 Using PowerQuery, I have a query for each of the 15 sub assemblies mentioned above for each of the 16 sections.使用 PowerQuery,我对上面提到的 16 个部分中的每一个的 15 个子程序集都有一个查询。 In these queries I am using a parameter that looks at the relevant named cell value rather than a hard coded value.在这些查询中,我使用了一个查看相关命名单元格值而不是硬编码值的参数。 This means I will only have 240 queries rather than 700+.这意味着我将只有 240 个查询而不是 700+。

(eg let Source = Sql.Database("x_BJMCC\\SQLEXPRESS", "AMX"), dbo_AU_ARE_22_36_GA11_GA11_R_13_3__ANSI_61_ = Source{[Schema="dbo",Item= GetValue("ARE_Section01") ]}[Data] in dbo_AU_ARE_22_36_GA11_GA11_R_13_3__ANSI_61_ ) (例如,让 Source = Sql.Database("x_BJMCC\\SQLEXPRESS", "AMX"), dbo_AU_ARE_22_36_GA11_GA11_R_13_3__ANSI_61_ = Source{[Schema="dbo",Item= GetValue("ARE_Section01") ]}[Data_2_AU_1GA1_GA11_GA11_GA11_GA11_136_16_1_2_AU_1_GA11_GA1_16_16_1GA_16_AMX_10_16_16_16_16_16_11_aMX

I then have a query for each of the 16 Sections which appends all the relevant sub assemblies.然后我对附加所有相关子程序集的 16 个部分中的每一个都有一个查询。 I then have a top level Panel query that appends all Section queries.然后我有一个顶级面板查询,它附加了所有部分查询。

I hope I have explained this properly so far.....我希望到目前为止我已经正确解释了这一点......

My problem is this...我的问题是这个...

When I hard code the assembly names into the queries the information gets pulled very quickly from SQL.当我将程序集名称硬编码到查询中时,信息会很快从 SQL 中提取出来。 But when I use the parameters (as above) its a lot slower.但是当我使用参数(如上)时,它的速度要慢得多。

Has anyone got any tips on how I can improve performance?有没有人对我如何提高性能有任何提示?

I guess, the problem is with your GetValue function.我猜,问题出在你的 GetValue 函数上。 For example, using fnGetParameter function by Ken Puls doesn't break query folding.例如,使用 Ken Puls 的fnGetParameter函数不会破坏查询折叠。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM