
如果在连接数据库时选择sql导入,powrquery查询会发生两次,一次获取整个表的标题与结构,强制返回0行,另外一次查询返回所有数据。

Table.View函数可以触发折叠查询,阻止sql的两次查询,
Table.View只能将sql导入操作这一步翻译成折叠查询,阻止2次查询
注意:如果pq中间很多操作是无法进行查询折叠的,Table.View用在最后也不会将前面的的无法查询折叠的操作翻译成可以查询折叠的
let
源 = Sql.Database("L\l1", "test", [Query="SELECT [date]#(lf) ,[ty]#(lf)#(lf) FROM [test].[dbo].[Sheet35]"]),
bm=Table.View(
null,
[GetType=()=> type table[
date=Text.Type,
ty=Text.Type]
,GetRows=()=>源,Ontake=
(count as number )=>
if count = 0
then #table(GetType(),{})
else Table.FirstN(源,count)
])
in
bm
网友评论