如何在多个分区上执行 SQL 选择?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4268139/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How does one do a SQL select over multiple partitions?
提问by Yusufk
Is there a more efficient way than:
有没有比以下更有效的方法:
select * from transactions partition( partition1 )
union all
select * from transactions partition( partition2 )
union all
select * from transactions partition( partition3 );
回答by Justin Cave
It should be exceptionally rare that you use the PARTITION( partitionN ) syntax in a query.
在查询中使用 PARTITION( partitionN ) 语法应该是非常罕见的。
You would normally just want to specify values for the partition key and allow Oracle to perform partition elimination. If your table is partitioned daily based on TRANSACTION_DATE, for example
您通常只想为分区键指定值并允许 Oracle 执行分区消除。例如,如果您的表每天根据 TRANSACTION_DATE 进行分区
SELECT *
FROM transactions
WHERE transaction_date IN (date '2010-11-22',
date '2010-11-23',
date '2010-11-24')
would select all the data from today's partition, yesterday's partition, and the day before's partition.
将从今天的分区、昨天的分区和前一天的分区中选择所有数据。
回答by erbsock
Can you provide additional context? What are your predicates? What makes you think that you need to explicitly tell the optimizer to go against multiple partitions. You may have the wrong partition key in use, for example.
你能提供额外的背景吗?你的谓词是什么?是什么让您认为您需要明确告诉优化器针对多个分区。例如,您可能使用了错误的分区键。