Search code examples
oracle-databasedatabase-partitioning

Oracle `partition_by` in select clauses, does it create these partitions permantly?


I only have a superficial understanding on partitions in Oracle, but, I know you can create persistent partitions on Oracle, for example within a create table statement, but, when using partition by clauses within a select statement? Will Oracle create a persistent partition, for caching reasons or whatever, or will the partition be "temporary" in some sense (e.g., it will be removed at the end of the session, the query, or after some time...)?

For example, for a query like

SELECT col1, first_value(col2)
                over (partition by col3 order by col2 nulls last) as colx
FROM tbl

If I execute that query, will Oracle create a partition to speed up the execution if I execute it again, tomorrow or three months later? I'm worry about that because I don't know if it could cause memory exhaustion if I abuse that feature.


Solution

  • partition by is used in the query(windows function) to fetch the aggregated result using the windows function which is grouped by the columns mentioned in the partition by. It behaves like group by but has ability to provide grouped result for each row without actually grouping the final outcome.

    It has nothing to do with table/index partition.

    scope of this partition by is just this query and have no impact on table structure.