Optimizing huge value list in Teradata without volatile tables

拜拜、爱过 提交于 2021-01-28 04:11:30

问题


Have a value list like`

`where a.c1 in ( list ) `

Then shoving the list in the volatile table is the best way out. However this is being done via cognos & IBM isn't smart enough to know what Teradata's volatile table is. I wish It was so I could use exclusion logic Exists to go through the volatile table contents. So without volatile table , I have a value list where a.c1 in ( list ) which has like 5K values. Keeping that list in the report is proving expensive. I wondered if it was possible to store this kind of list some place before bringing it in the report. How about CTE and using exists on a CTE , would that achieve similar gains.


回答1:


You can pass the list as a string and then split it into a table, e.g. for a list of integers:

where a.c1 in
 (
   SELECT CAST(token AS INT)
   FROM TABLE (STRTOK_SPLIT_TO_TABLE(1, '1,2,3,4,5,6,7,8,9,5000', ',')
        RETURNS (outkey INTEGER,
                 tokennum INTEGER,
                 token VARCHAR(10) CHARACTER SET UNICODE)
              ) AS dt 
 )

Of course the optimizer has no knowledge about the number of rows returned, so better check Explain...



来源:https://stackoverflow.com/questions/33521496/optimizing-huge-value-list-in-teradata-without-volatile-tables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!