SQL 如何在多个分区上进行选择?

发布于 2024-10-04 04:19:54 字数 225 浏览 1 评论 0原文

有没有比以下更有效的方法:

select * from transactions partition( partition1 ) 
union all 
select * from transactions partition( partition2 ) 
union all 
select * from transactions partition( partition3 ); 

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 ); 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

許願樹丅啲祈禱 2024-10-11 04:19:54

在查询中使用 PARTITION(partitionN) 语法的情况应该非常罕见。

您通常只想指定分区键的值并允许 Oracle 执行分区消除。例如,如果您的表根据 TRANSACTION_DATE 每天进行分区,

SELECT *
  FROM transactions
 WHERE transaction_date IN (date '2010-11-22', 
                            date '2010-11-23', 
                            date '2010-11-24')

则将从今天的分区、昨天的分区和前天的分区中选择所有数据。

It should be exceptionally rare that you use the PARTITION( partitionN ) syntax in a query.

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

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.

夜司空 2024-10-11 04:19:54

您能提供更多背景信息吗?你的谓词是什么?是什么让您认为您需要明确告诉优化器针对多个分区。例如,您可能使用了错误的分区键。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文