我正在尝试从分区表中的多个分区中选择数据。它适用于单个分区(select * from table partition(ParititonName)
,但不能选择多个分区(select * from table partitions(Part1,part2)
。
您能否让我知道如何在单个查询中选择多个分区。
如果您需要在查询中显式地处理分区名称 - 这不是典型的用例(因为您经常使用 WHERE 谓词分区修剪) - 但可能是这样的情况hash partitioning
,你可以使用UNION ALL
访问更多分区。
select * from TAB partition (Part1)
union all
select * from TAB partition (Part2);
The 执行计划 https://stackoverflow.com/questions/34975406/how-to-describe-performance-issue-in-relational-database?answertab=oldest#tab-top显示(参见 Pstart 和 Pstop 列)仅访问分区 1 和 2。
----------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
----------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 86 | 4 (0)| 00:00:01 | | |
| 1 | UNION-ALL | | | | | | | |
| 2 | PARTITION HASH SINGLE | | 1 | 43 | 2 (0)| 00:00:01 | 1 | 1 |
| 3 | TABLE ACCESS STORAGE FULL| TAB | 1 | 43 | 2 (0)| 00:00:01 | 1 | 1 |
| 4 | PARTITION HASH SINGLE | | 1 | 43 | 2 (0)| 00:00:01 | 2 | 2 |
| 5 | TABLE ACCESS STORAGE FULL| TAB | 1 | 43 | 2 (0)| 00:00:01 | 2 | 2 |
----------------------------------------------------------------------------------------------------
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)