diff --git a/README.md b/README.md index eb82be72..46f0efe6 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ This repository stores a variety of examples demonstrating how to use the Oracle | ------------- | ------------- | | [db-sample-schemas](https://github.com/oracle/db-sample-schemas) | Git submodule of the Oracle Database Sample Schemas | | [dotnet](./dotnet) | .NET based examples | +| [exadata-express](./exadata-express) | Exadata Express examples | | [java](./java) | Java based examples | | [javascript](./javascript) | JavaScript based examples | | [optimizer](./optimizer) | Oracle Optmizer and Optimizer Stats examples | diff --git a/exadata-express/Query.py b/exadata-express/Query.py new file mode 100644 index 00000000..f446717b --- /dev/null +++ b/exadata-express/Query.py @@ -0,0 +1,37 @@ +#------------------------------------------------------------------------------ +# Query.py +# +# Demonstrate how to perform a query of a database schema, configured with Oracle's sample HR Schema, in your Exadata Express +# Cloud Service. +# +# Before running this app: +# 1. From the Exadata Express Cloud Service Console, click on Develop, then click on Python. Follow displayed instructions to: +# - Install instant client. +# - Enable client access and download your Exadata Express Cloud Service credentials. +# - Install the Python Extension module (cx_Oracle) to enable access to your cloud service. +# 2. Create a schema using the Exadata Express Cloud Service Console. Remember the schema name and password for step 4. +# 3. Configure the schema with Oracle's Sample HR Schema. Scripts to configure this schema can be found on GitHub. +# See github.com/oracle/db-sample-schemas for scripts and instructions. +# 4. Modify cx_Oracle.connect to connect to the HR schema you created in step 2: +# - The first value is the name of your HR schema. +# - The second value is the password for your HR schema. +# - The third value is "dbaccess", which is defined in the wallet downloaded from the Exadata Express Cloud Service +#------------------------------------------------------------------------------ + +from __future__ import print_function + +import cx_Oracle + + +connection = cx_Oracle.connect('HR',password,'dbaccess') + +sql = """ +select * from employees where department_id = 90""" + + +print("Get all rows via iterator") +cursor = connection.cursor() +for result in cursor.execute(sql): + print(result) +print() + diff --git a/java/AoJ/README.md b/java/AoJ/README.md old mode 100644 new mode 100755 index 369749e9..79ea671d --- a/java/AoJ/README.md +++ b/java/AoJ/README.md @@ -3,9 +3,12 @@ ADBA is Asynchronous Database Access, a non-blocking database access api that Oracle is proposing as a Java standard. ADBA was announced at [JavaOne 2016](https://static.rainfocus.com/oracle/oow16/sess/1461693351182001EmRq/ppt/CONF1578%2020160916.pdf) -and presented again at [JavaOne 2017](http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf). -The ADBA source is available for download from the [OpenJDK sandbox](http://hg.openjdk.java.net/jdk/sandbox/file/9d3b0eb749a9/src/jdk.incubator.adba) -as part of the OpenJDK project and the JavaDoc is available [here](http://cr.openjdk.java.net/~lancea/8188051/apidoc/jdk.incubator.adba-summary.html). +and presented again at +[JavaOne 2017](http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf). +The ADBA source is available for download from the +[OpenJDK sandbox](http://hg.openjdk.java.net/jdk/sandbox/file/JDK-8188051-branch/src/jdk.incubator.adba/share/classes) +as part of the OpenJDK project and the JavaDoc is available +[here](http://cr.openjdk.java.net/~lancea/8188051/apidoc/jdk.incubator.adba-summary.html). You can get involved in the ADBA specification effort by following the [JDBC Expert Group mailing list](http://mail.openjdk.java.net/pipermail/jdbc-spec-discuss/). @@ -18,7 +21,7 @@ JDBC driver. AoJ implements only a small part of ADBA, but it is enough to write interesting code. It provides partial implementations of ```DataSourceFactory```, ```DataSource```, -```Connection```, ```OperationGroup```, ```RowOperation```, ```CountOperation```, +```Session```, ```OperationGroup```, ```RowOperation```, ```CountOperation```, ```Transaction``` and others. These implementations are not complete but there is enough there to write interesting database programs. The code that is there is untested, but it does work to some extent. The saving grace is that you can @@ -36,15 +39,8 @@ better to get it to the community as soon as we could. We hope that you agree. ## Building AoJ AoJ and ADBA require JDK 9 or later. Download ADBA from the -[OpenJDK sandbox](http://hg.openjdk.java.net/jdk/sandbox/file/JDK-8188051-branch/src/jdk.incubator.adba/share/classes). It does not have any dependencies outside of Java SE. - -For building the API modules: -``` -$ mkdir -p mods/jdk.incubator.adba -$ javac -d mods/jdk.incubator.adba/ $(find jdk.incubator.adba -name "*.java") -$ jar --create --file=mlib/jdk.incubator.adba.jar --module-version=1.0 -C mods/jdk.incubator.adba/ . -```` -Download AoJ from +[OpenJDK sandbox](http://hg.openjdk.java.net/jdk/sandbox/file/JDK-8188051-branch/src/jdk.incubator.adba/share/classes). +It does not have any dependencies outside of Java SE 9. Download AoJ from [GitHub](https://github.com/oracle/oracle-db-examples/tree/master/java/AoJ). Both are modularized so be sure to include the module-info.java files. AoJ depends on ADBA. The AoJ sample file depends on JUnit which is included with most IDEs but is @@ -59,7 +55,7 @@ driver. The sample file uses the scott/tiger schema available Start the database and load ```scott.sql```. Edit ```com.oracle.adbaoverjdbc.test.FirstLight.java``` and set the constant ```URL``` to an appropriate value. AoJ will pass this value -to ```java.sql.DriverManager.getConnection```. If you are using a database other +to ```java.sql.DriverManager.getSession```. If you are using a database other than Oracle you should change the value of the constant ```TRIVIAL``` to some very trivial ```SELECT``` query. @@ -68,34 +64,36 @@ very trivial ```SELECT``` query. The following test case should give you some idea of what AoJ can do. It should run with any JDBC driver connecting to a database with the scott schema. This is the last test in ```com.oracle.adbaoverjdbc.test.FirstLight.java```. For an -introduction to ADBA see the [JavaOne 2017 presentation](http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf). +introduction to ADBA see the +[JavaOne 2017 presentation](http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf). -```public void transactionSample() { +``` + public void readme(String url, String user, String password) { // get the AoJ DataSourceFactory - DataSourceFactory factory = DataSourceFactory.forName("com.oracle.adbaoverjdbc.DataSourceFactory"); - // get a DataSource and a Connection + DataSourceFactory factory = DataSourceFactory.newFactory("com.oracle.adbaoverjdbc.DataSourceFactory"); + // get a DataSource and a Session try (DataSource ds = factory.builder() - .url(URL) - .username(“scott") - .password(“tiger") + .url(url) + .username(user) + .password(password) .build(); - Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.getMessage()))) { - // get a Transaction - Transaction trans = conn.transaction(); + Session conn = ds.getSession(t -> System.out.println("ERROR: " + t.getMessage()))) { + // get a TransactionCompletion + TransactionCompletion trans = conn.transactionCompletion(); // select the EMPNO of CLARK CompletionStage idF = conn.rowOperation("select empno, ename from emp where ename = ? for update") .set("1", "CLARK", AdbaType.VARCHAR) .collect(Collector.of( () -> new int[1], - (a, r) -> {a[0] = r.get("empno", Integer.class); }, + (a, r) -> {a[0] = r.at("empno").get(Integer.class); }, (l, r) -> null, a -> a[0]) ) .submit() .getCompletionStage(); // update CLARK to work in department 50 - conn.countOperation("update emp set deptno = ? where empno = ?") + conn.rowCountOperation("update emp set deptno = ? where empno = ?") .set("1", 50, AdbaType.INTEGER) .set("2", idF, AdbaType.INTEGER) .apply(c -> { @@ -114,15 +112,15 @@ introduction to ADBA see the [JavaOne 2017 presentation](http://www.oracle.com/t // wait for the async tasks to complete before exiting ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES); } -``` +``` ## AoJ Design Spec in 100 words or less The methods called by the user thread create a network -(i.e., [DAG](https://en.wikipedia.org/wiki/Directed_acyclic_graph)) of +([DAG](https://en.wikipedia.org/wiki/Directed_acyclic_graph)) of ```CompletableFuture```s. These ```CompleteableFuture```s asynchronously execute the synchronous JDBC calls and the result processing code provided by the user code. By default AoJ uses ```ForkJoinPool.commonPool()``` to execute ```CompletableFuture```s but the user code can provide another ```Executor```. -When the ```Connection``` is submitted the root of the ```CompleteableFuture``` +When the ```Session``` is submitted the root of the ```CompleteableFuture``` network is completed triggering execution of the rest of the network. diff --git a/java/AoJ/src/README.md b/java/AoJ/src/README.md new file mode 100755 index 00000000..79ea671d --- /dev/null +++ b/java/AoJ/src/README.md @@ -0,0 +1,126 @@ +# AoJ: ADBA over JDBC + +ADBA is Asynchronous Database Access, a non-blocking database access api that +Oracle is proposing as a Java standard. ADBA was announced at +[JavaOne 2016](https://static.rainfocus.com/oracle/oow16/sess/1461693351182001EmRq/ppt/CONF1578%2020160916.pdf) +and presented again at +[JavaOne 2017](http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf). +The ADBA source is available for download from the +[OpenJDK sandbox](http://hg.openjdk.java.net/jdk/sandbox/file/JDK-8188051-branch/src/jdk.incubator.adba/share/classes) +as part of the OpenJDK project and the JavaDoc is available +[here](http://cr.openjdk.java.net/~lancea/8188051/apidoc/jdk.incubator.adba-summary.html). +You can get involved in the ADBA specification effort by following the +[JDBC Expert Group mailing list](http://mail.openjdk.java.net/pipermail/jdbc-spec-discuss/). + +Reading a bunch of JavaDoc and interfaces can be interesting, but it is not nearly +as engaging as having actual running code to play with. To that end, we have +uploaded the beginnings of an implementation of ADBA running over standard JDBC, +AoJ. AoJ is available for download from [GitHub](https://github.com/oracle/oracle-db-examples/tree/master/java/AoJ) +under the Apache license. It should run with any reasonably standard compliant +JDBC driver. + +AoJ implements only a small part of ADBA, but it is enough to write interesting +code. It provides partial implementations of ```DataSourceFactory```, ```DataSource```, +```Session```, ```OperationGroup```, ```RowOperation```, ```CountOperation```, +```Transaction``` and others. These implementations are not complete but there is +enough there to write interesting database programs. The code that is there is +untested, but it does work to some extent. The saving grace is that you can +download the source and improve it: add new features, fix bugs, try out alternate +implementations. + +Oracle is not proposing AoJ as an open source project. However, because AoJ is +released under the Apache license, the Java community can fork the code and create +a true open source project with this upload as a base. Oracle developers may +contribute when we have time, but this would have to be a Java community effort. + +We could have held this code back and worked on it longer. Instead we thought it +better to get it to the community as soon as we could. We hope that you agree. + +## Building AoJ + +AoJ and ADBA require JDK 9 or later. Download ADBA from the +[OpenJDK sandbox](http://hg.openjdk.java.net/jdk/sandbox/file/JDK-8188051-branch/src/jdk.incubator.adba/share/classes). +It does not have any dependencies outside of Java SE 9. Download AoJ from +[GitHub](https://github.com/oracle/oracle-db-examples/tree/master/java/AoJ). Both +are modularized so be sure to include the module-info.java files. AoJ depends on +ADBA. The AoJ sample file depends on JUnit which is included with most IDEs but is +also available [here](https://github.com/junit-team/junit4). + +To run the sample file you will need a SQL database and corresponding JDBC driver. AoJ +has been run with [Oracle Database 12c](http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html) +and [Oracle Database 12c JDBC](http://www.oracle.com/technetwork/database/application-development/jdbc/downloads/index.html), +but it should work with any reasonably standard compliant SQL database and JDBC +driver. The sample file uses the scott/tiger schema available +[here](https://github.com/oracle/dotnet-db-samples/blob/master/schemas/scott.sql). + +Start the database and load ```scott.sql```. Edit ```com.oracle.adbaoverjdbc.test.FirstLight.java``` +and set the constant ```URL``` to an appropriate value. AoJ will pass this value +to ```java.sql.DriverManager.getSession```. If you are using a database other +than Oracle you should change the value of the constant ```TRIVIAL``` to some +very trivial ```SELECT``` query. + +## Sample Code + +The following test case should give you some idea of what AoJ can do. It should +run with any JDBC driver connecting to a database with the scott schema. This is +the last test in ```com.oracle.adbaoverjdbc.test.FirstLight.java```. For an +introduction to ADBA see the +[JavaOne 2017 presentation](http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf). + + +``` + public void readme(String url, String user, String password) { + // get the AoJ DataSourceFactory + DataSourceFactory factory = DataSourceFactory.newFactory("com.oracle.adbaoverjdbc.DataSourceFactory"); + // get a DataSource and a Session + try (DataSource ds = factory.builder() + .url(url) + .username(user) + .password(password) + .build(); + Session conn = ds.getSession(t -> System.out.println("ERROR: " + t.getMessage()))) { + // get a TransactionCompletion + TransactionCompletion trans = conn.transactionCompletion(); + // select the EMPNO of CLARK + CompletionStage idF = conn.rowOperation("select empno, ename from emp where ename = ? for update") + .set("1", "CLARK", AdbaType.VARCHAR) + .collect(Collector.of( + () -> new int[1], + (a, r) -> {a[0] = r.at("empno").get(Integer.class); }, + (l, r) -> null, + a -> a[0]) + ) + .submit() + .getCompletionStage(); + // update CLARK to work in department 50 + conn.rowCountOperation("update emp set deptno = ? where empno = ?") + .set("1", 50, AdbaType.INTEGER) + .set("2", idF, AdbaType.INTEGER) + .apply(c -> { + if (c.getCount() != 1L) { + trans.setRollbackOnly(); + throw new SqlException("updated wrong number of rows", null, null, -1, null, -1); + } + return c.getCount(); + }) + .onError(t -> t.printStackTrace()) + .submit(); + + conn.catchErrors(); // resume normal execution if there were any errors + conn.commitMaybeRollback(trans); // commit (or rollback) the transaction + } + // wait for the async tasks to complete before exiting + ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES); + } +``` + +## AoJ Design Spec in 100 words or less + +The methods called by the user thread create a network +([DAG](https://en.wikipedia.org/wiki/Directed_acyclic_graph)) of +```CompletableFuture```s. These ```CompleteableFuture```s asynchronously execute +the synchronous JDBC calls and the result processing code provided by the user +code. By default AoJ uses ```ForkJoinPool.commonPool()``` to execute +```CompletableFuture```s but the user code can provide another ```Executor```. +When the ```Session``` is submitted the root of the ```CompleteableFuture``` +network is completed triggering execution of the rest of the network. diff --git a/java/AoJ/src/ReadMe.java b/java/AoJ/src/ReadMe.java new file mode 100755 index 00000000..45fb9406 --- /dev/null +++ b/java/AoJ/src/ReadMe.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ReadMe; + +import java.util.concurrent.CompletionStage; +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collector; +import jdk.incubator.sql2.AdbaType; +import jdk.incubator.sql2.DataSource; +import jdk.incubator.sql2.DataSourceFactory; +import jdk.incubator.sql2.Session; +import jdk.incubator.sql2.SqlException; +import jdk.incubator.sql2.TransactionCompletion; + +/** + * + */ +public class ReadMe { + + public void readme(String url, String user, String password) { + // get the AoJ DataSourceFactory + DataSourceFactory factory = DataSourceFactory.newFactory("com.oracle.adbaoverjdbc.DataSourceFactory"); + // get a DataSource and a Session + try (DataSource ds = factory.builder() + .url(url) + .username(user) + .password(password) + .build(); + Session conn = ds.getSession(t -> System.out.println("ERROR: " + t.getMessage()))) { + // get a TransactionCompletion + TransactionCompletion trans = conn.transactionCompletion(); + // select the EMPNO of CLARK + CompletionStage idF = conn.rowOperation("select empno, ename from emp where ename = ? for update") + .set("1", "CLARK", AdbaType.VARCHAR) + .collect(Collector.of( + () -> new int[1], + (a, r) -> {a[0] = r.at("empno").get(Integer.class); }, + (l, r) -> null, + a -> a[0]) + ) + .submit() + .getCompletionStage(); + // update CLARK to work in department 50 + conn.rowCountOperation("update emp set deptno = ? where empno = ?") + .set("1", 50, AdbaType.INTEGER) + .set("2", idF, AdbaType.INTEGER) + .apply(c -> { + if (c.getCount() != 1L) { + trans.setRollbackOnly(); + throw new SqlException("updated wrong number of rows", null, null, -1, null, -1); + } + return c.getCount(); + }) + .onError(t -> t.printStackTrace()) + .submit(); + + conn.catchErrors(); // resume normal execution if there were any errors + conn.commitMaybeRollback(trans); // commit (or rollback) the transaction + } + // wait for the async tasks to complete before exiting + ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES); + } + +} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/CountOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/CountOperation.java old mode 100644 new mode 100755 index 19e1e6ea..7ef59922 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/CountOperation.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/CountOperation.java @@ -15,8 +15,6 @@ */ package com.oracle.adbaoverjdbc; -import jdk.incubator.sql2.ParameterizedCountOperation; -import jdk.incubator.sql2.Result; import jdk.incubator.sql2.RowOperation; import jdk.incubator.sql2.SqlException; import jdk.incubator.sql2.SqlType; @@ -27,13 +25,16 @@ import java.util.concurrent.Executor; import java.util.function.Consumer; import java.util.function.Function; +import java.util.logging.Level; +import jdk.incubator.sql2.ParameterizedRowCountOperation; +import jdk.incubator.sql2.Result; /** * * @param */ class CountOperation extends ParameterizedOperation - implements ParameterizedCountOperation { + implements ParameterizedRowCountOperation { static private final Function DEFAULT_PROCESSOR = c -> null; @@ -41,23 +42,23 @@ class CountOperation extends ParameterizedOperation * Factory method to create CountOperations. * * @param the type of the value of the CountOperation - * @param conn the Connection the CountOperation belongs to + * @param session the Session the CountOperation belongs to * @param grp the GroupOperation the CountOperation is a member of * @param sql the SQL string to execute. Must return a count. * @return a new CountOperation that will execute sql. */ - static CountOperation newCountOperation(Connection conn, OperationGroup grp, String sql) { - return new CountOperation<>(conn, grp, sql); + static CountOperation newCountOperation(Session session, OperationGroup grp, String sql) { + return new CountOperation<>(session, grp, sql); } // attributes private final String sqlString; - private Function countProcessor; + private Function countProcessor; PreparedStatement jdbcStatement; - CountOperation(Connection conn, OperationGroup operationGroup, String sql) { - super(conn, operationGroup); + CountOperation(Session session, OperationGroup operationGroup, String sql) { + super(session, operationGroup); countProcessor = DEFAULT_PROCESSOR; sqlString = sql; } @@ -68,7 +69,7 @@ public RowOperation returning(String... keys) { } @Override - public CountOperation apply(Function processor) { + public CountOperation apply(Function processor) { if (isImmutable() || countProcessor != DEFAULT_PROCESSOR) throw new IllegalStateException("TODO"); if (processor == null) throw new IllegalArgumentException("TODO"); countProcessor = processor; @@ -92,13 +93,13 @@ CompletionStage follows(CompletionStage predecessor, Executor executor) { private T executeQuery(Object ignore) { checkCanceled(); try { - jdbcStatement = connection.prepareStatement(sqlString); + jdbcStatement = session.prepareStatement(sqlString); setParameters.forEach((String k, ParameterValue v) -> { v.set(jdbcStatement, k); }); - System.out.println("executeUpdate(\"" + sqlString + "\")"); + group.logger.log(Level.FINE, () -> "executeUpdate(\"" + sqlString + "\")"); long c = jdbcStatement.executeLargeUpdate(); - return countProcessor.apply(new Count(c)); + return countProcessor.apply(new RowCount(c)); } catch (SQLException ex) { throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), sqlString, -1); @@ -147,11 +148,11 @@ public CountOperation onError(Consumer handler) { * also may be non-numeric return values that Result.Count could express, eg * success but number unknown. */ - static class Count implements Result.Count { + static class RowCount implements Result.RowCount { private long count = -1; - private Count(long c) { + private RowCount(long c) { count = c; } diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSource.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSource.java old mode 100644 new mode 100755 index 0543d9ae..42fb269b --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSource.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSource.java @@ -15,53 +15,53 @@ */ package com.oracle.adbaoverjdbc; -import jdk.incubator.sql2.ConnectionProperty; +import jdk.incubator.sql2.SessionProperty; import java.util.HashSet; import java.util.Map; import java.util.Set; /** - * Bare bones DataSource. No support for Connection caching. + * Bare bones DataSource. No support for Session caching. * */ class DataSource implements jdk.incubator.sql2.DataSource { - static DataSource newDataSource(Map defaultConnectionProperties, - Map requiredConnectionProperties) { - return new DataSource(defaultConnectionProperties, requiredConnectionProperties); + static DataSource newDataSource(Map defaultSessionProperties, + Map requiredSessionProperties) { + return new DataSource(defaultSessionProperties, requiredSessionProperties); } - protected final Map defaultConnectionProperties; - protected final Map requiredConnectionProperties; + protected final Map defaultSessionProperties; + protected final Map requiredSessionProperties; - protected final Set openConnections = new HashSet<>(); + protected final Set openSessions = new HashSet<>(); - protected DataSource(Map defaultProps, - Map requiredProps) { + protected DataSource(Map defaultProps, + Map requiredProps) { super(); - defaultConnectionProperties = defaultProps; - requiredConnectionProperties = requiredProps; + defaultSessionProperties = defaultProps; + requiredSessionProperties = requiredProps; } @Override - public Connection.Builder builder() { - return ConnectionBuilder.newConnectionBuilder(this, defaultConnectionProperties, requiredConnectionProperties); + public Session.Builder builder() { + return SessionBuilder.newSessionBuilder(this, defaultSessionProperties, requiredSessionProperties); } @Override public void close() { - openConnections.stream().forEach( c -> c.close() ); + openSessions.stream().forEach( c -> c.close() ); } - DataSource registerConnection(Connection c) { - openConnections.add(c); + DataSource registerSession(Session c) { + openSessions.add(c); return this; } - DataSource deregisterConnection(Connection c) { - openConnections.remove(c); + DataSource deregisterSession(Session c) { + openSessions.remove(c); return this; } diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceBuilder.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceBuilder.java old mode 100644 new mode 100755 index 12e8f1e4..3e96f988 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceBuilder.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceBuilder.java @@ -15,9 +15,11 @@ */ package com.oracle.adbaoverjdbc; -import jdk.incubator.sql2.ConnectionProperty; +import jdk.incubator.sql2.SessionProperty; import java.util.HashMap; import java.util.Map; +import java.util.function.LongConsumer; +import jdk.incubator.sql2.DataSourceProperty; /** * @@ -30,59 +32,81 @@ static DataSourceBuilder newDataSourceBuilder() { protected boolean isBuilt = false; + Map dataSourceProperties = new HashMap<>(); + /** - * defaultConnectionProperties can be overridden by a ConnectionBuilder + * defaultSessionProperties can be overridden by a SessionBuilder */ - Map defaultConnectionProperties = new HashMap<>(); + Map defaultSessionProperties = new HashMap<>(); /** - * it is an error if a ConnectionBuilder tries to override requiredConnectionProperties + * it is an error if a SessionBuilder tries to override requiredSessionProperties */ - Map requiredConnectionProperties = new HashMap<>(); + Map requiredSessionProperties = new HashMap<>(); @Override - public jdk.incubator.sql2.DataSource.Builder defaultConnectionProperty(ConnectionProperty property, Object value) { + public jdk.incubator.sql2.DataSource.Builder property(DataSourceProperty property, Object value) { if (isBuilt) { throw new IllegalStateException("TODO"); } - if (defaultConnectionProperties.containsKey(property)) { + if (dataSourceProperties.containsKey(property)) { + throw new IllegalArgumentException("cannot set a property multiple times"); + } + if (!property.validate(value)) { + throw new IllegalArgumentException("TODO"); + } + dataSourceProperties.put(property, value); + return this; + } + + @Override + public jdk.incubator.sql2.DataSource.Builder defaultSessionProperty(SessionProperty property, Object value) { + if (isBuilt) { + throw new IllegalStateException("TODO"); + } + if (defaultSessionProperties.containsKey(property)) { throw new IllegalArgumentException("cannot set a default multiple times"); } - if (requiredConnectionProperties.containsKey(property)) { + if (requiredSessionProperties.containsKey(property)) { throw new IllegalArgumentException("cannot set a default that is already required"); } if (!property.validate(value)) { throw new IllegalArgumentException("TODO"); } - defaultConnectionProperties.put(property, value); + defaultSessionProperties.put(property, value); return this; } @Override - public jdk.incubator.sql2.DataSource.Builder connectionProperty(ConnectionProperty property, Object value) { + public jdk.incubator.sql2.DataSource.Builder sessionProperty(SessionProperty property, Object value) { if (isBuilt) { throw new IllegalStateException("TODO"); } - if (defaultConnectionProperties.containsKey(property)) { + if (defaultSessionProperties.containsKey(property)) { throw new IllegalArgumentException("cannot set a required prop that has a default"); } - if (requiredConnectionProperties.containsKey(property)) { + if (requiredSessionProperties.containsKey(property)) { throw new IllegalArgumentException("cannot set a required prop multiple times"); } if (!property.validate(value)) { throw new IllegalArgumentException("TODO"); } - requiredConnectionProperties.put(property, value); + requiredSessionProperties.put(property, value); return this; } + @Override + public jdk.incubator.sql2.DataSource.Builder requestHook(LongConsumer request) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + @Override public jdk.incubator.sql2.DataSource build() { if (isBuilt) { throw new IllegalStateException("cannot build more than once. All objects are use-once"); } isBuilt = true; - return DataSource.newDataSource(defaultConnectionProperties, requiredConnectionProperties); + return DataSource.newDataSource(defaultSessionProperties, requiredSessionProperties); } } diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceFactory.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceFactory.java old mode 100644 new mode 100755 diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java old mode 100644 new mode 100755 index d285e279..6205fca5 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java @@ -18,12 +18,12 @@ import java.util.Properties; /** - * An ADBA ConnectionProperty that specifies a set of JDBC connection properties. + * An ADBA SessionProperty that specifies a set of JDBC Connection properties. * Its value is a java.util.Properties. This value is passed as the info argument * when creating a java.sql.Connection. * */ -public class JdbcConnectionProperties implements jdk.incubator.sql2.ConnectionProperty { +public class JdbcConnectionProperties implements jdk.incubator.sql2.SessionProperty { public static final JdbcConnectionProperties JDBC_CONNECTION_PROPERTIES = new JdbcConnectionProperties(); diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Operation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Operation.java old mode 100644 new mode 100755 index 6d7d982d..16f57056 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Operation.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Operation.java @@ -146,16 +146,19 @@ static Throwable unwrapException(Throwable ex) { protected Consumer errorHandler = null; // internal state - protected final Connection connection; + protected final Session session; protected final OperationGroup group; protected OperationLifecycle operationLifecycle = OperationLifecycle.MUTABLE; + + // used only by Session + protected Operation() { + session = (Session)this; + group = (OperationGroup)this; + } - Operation(Connection conn, OperationGroup operationGroup) { - // passing null for connection and operationGroup is a hack. It is not - // possible to pass _this_ to a super constructor so we define null to mean - // _this_. Yuck. Only used by Connection. - connection = conn == null ? (Connection) this : conn; - group = operationGroup == null ? (OperationGroup) this : operationGroup; + Operation(Session session, OperationGroup operationGroup) { + this.session = session; + group = operationGroup; } @Override @@ -216,7 +219,7 @@ long getTimeoutMillis() { } protected Executor getExecutor() { - return connection.getExecutor(); + return session.getExecutor(); } /** diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java old mode 100644 new mode 100755 index 1f31a0ad..4ac53e78 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java @@ -15,24 +15,24 @@ */ package com.oracle.adbaoverjdbc; -import jdk.incubator.sql2.ArrayCountOperation; import jdk.incubator.sql2.LocalOperation; +import jdk.incubator.sql2.MultiOperation; import jdk.incubator.sql2.OutOperation; -import jdk.incubator.sql2.ParameterizedCountOperation; import jdk.incubator.sql2.ParameterizedRowOperation; -import jdk.incubator.sql2.RowProcessorOperation; import jdk.incubator.sql2.Submission; -import jdk.incubator.sql2.Transaction; import jdk.incubator.sql2.TransactionOutcome; import java.time.Duration; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import java.util.concurrent.Executor; -import java.util.concurrent.Flow; import java.util.function.Consumer; +import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collector; -import jdk.incubator.sql2.MultiOperation; +import jdk.incubator.sql2.ParameterizedRowCountOperation; +import jdk.incubator.sql2.ParameterizedRowPublisherOperation; +import jdk.incubator.sql2.ArrayRowCountOperation; +import jdk.incubator.sql2.TransactionCompletion; /** * Only sequential, dependent, unconditional supported. @@ -77,17 +77,28 @@ class OperationGroup extends com.oracle.adbaoverjdbc.Operation (a, b) -> null, a -> null); - static OperationGroup newOperationGroup(Connection conn) { - return new OperationGroup(conn, conn); + static OperationGroup newOperationGroup(Session session) { + return new OperationGroup(session, session); + } + + static final Logger NULL_LOGGER = Logger.getAnonymousLogger(); + static { + NULL_LOGGER.setFilter(r -> false); + NULL_LOGGER.setLevel(Level.SEVERE); } + static final CompletionStage DEFAULT_CONDITION = CompletableFuture.completedFuture(true); + private boolean isParallel = false; private boolean isIndependent = false; - private CompletionStage condition = null; + private CompletionStage condition = DEFAULT_CONDITION; + private Submission submission = null; private Object accumulator; private Collector collector; + Logger logger = NULL_LOGGER; + /** * completed when this OperationGroup is no longer held. Completion of this * OperationGroup depends on held. @@ -107,8 +118,17 @@ static OperationGroup newOperationGroup(Connection conn) { */ private CompletionStage memberTail; - protected OperationGroup(Connection conn, OperationGroup group) { - super(conn, group); + // used only by Session. Will break if used by any other class. + protected OperationGroup() { + super(); + held = new CompletableFuture(); + head = new CompletableFuture(); + memberTail = head; + collector = DEFAULT_COLLECTOR; + } + + protected OperationGroup(Session session, OperationGroup group) { + super(session, group); held = new CompletableFuture(); head = new CompletableFuture(); memberTail = head; @@ -137,18 +157,19 @@ public jdk.incubator.sql2.OperationGroup conditional(CompletionStage submitHoldingForMoreMembers() { + public Submission submitHoldingForMoreMembers() { if ( isImmutable() || ! isHeld() ) throw new IllegalStateException("TODO"); //TODO prevent multiple calls accumulator = collector.supplier().get(); - return super.submit(); + submission = super.submit(); + return submission; } @Override - public jdk.incubator.sql2.OperationGroup releaseProhibitingMoreMembers() { + public jdk.incubator.sql2.Submission releaseProhibitingMoreMembers() { if ( ! isImmutable() || ! isHeld() ) throw new IllegalStateException("TODO"); held.complete(null); immutable(); // having set isHeld to false this call will make this OpGrp immutable - return this; + return submission; } @Override @@ -162,26 +183,26 @@ public OperationGroup collect(Collector c) { @Override public Operation catchOperation() { if (! isHeld() ) throw new IllegalStateException("TODO"); - return UnskippableOperation.newOperation(connection, this, op -> null); + return UnskippableOperation.newOperation(session, this, op -> null); } @Override - public ArrayCountOperation arrayCountOperation(String sql) { + public ArrayRowCountOperation arrayRowCountOperation(String sql) { if ( ! isHeld() ) throw new IllegalStateException("TODO"); throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override - public ParameterizedCountOperation countOperation(String sql) { + public ParameterizedRowCountOperation rowCountOperation(String sql) { if ( ! isHeld() ) throw new IllegalStateException("TODO"); if (sql == null) throw new IllegalArgumentException("TODO"); - return CountOperation.newCountOperation(connection, this, sql); + return CountOperation.newCountOperation(session, this, sql); } @Override public SqlOperation operation(String sql) { if ( !isHeld() ) throw new IllegalStateException("TODO"); - return SqlOperation.newOperation(connection, this, sql); + return SqlOperation.newOperation(session, this, sql); } @Override @@ -194,11 +215,11 @@ public OutOperation outOperation(String sql) { public ParameterizedRowOperation rowOperation(String sql) { if ( ! isHeld() ) throw new IllegalStateException("TODO"); if (sql == null) throw new IllegalArgumentException("TODO"); - return RowOperation.newRowOperation(connection, this, sql); + return RowOperation.newRowOperation(session, this, sql); } @Override - public RowProcessorOperation rowProcessorOperation(String sql) { + public ParameterizedRowPublisherOperation rowPublisherOperation(String sql) { if ( !isHeld() ) throw new IllegalStateException("TODO"); throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @@ -210,12 +231,12 @@ public MultiOperation multiOperation(String sql) { } @Override - public SimpleOperation endTransactionOperation(Transaction trans) { + public SimpleOperation endTransactionOperation(TransactionCompletion trans) { if ( ! isHeld() ) throw new IllegalStateException("TODO"); return com.oracle.adbaoverjdbc.SimpleOperation.newOperation( - connection, + session, (OperationGroup)this, - op -> connection.jdbcEndTransaction(op, (com.oracle.adbaoverjdbc.Transaction)trans)); + op -> session.jdbcEndTransaction(op, (com.oracle.adbaoverjdbc.TransactionCompletion)trans)); } @Override @@ -224,16 +245,11 @@ public LocalOperation localOperation() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } - @Override - public Flow.Processor, Submission> operationProcessor() { - if ( ! isHeld() ) throw new IllegalStateException("TODO"); - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - @Override public jdk.incubator.sql2.OperationGroup logger(Logger logger) { - if ( ! isHeld() ) throw new IllegalStateException("TODO"); - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + if ( logger == null ) throw new NullPointerException("OperationGroup.logger"); + else this.logger = logger; + return this; } @Override @@ -265,9 +281,20 @@ Submission submit(Operation op) { @Override CompletionStage follows(CompletionStage predecessor, Executor executor) { - head.complete(predecessor); // completing head allows members to execute - return held.thenCompose( h -> // when held completes memberTail holds the last member - memberTail.thenApplyAsync( t -> (T)collector.finisher().apply(accumulator), executor)); + return condition.thenCompose(cond -> { + if (cond) { + head.complete(predecessor); + return held.thenCompose(h + -> memberTail.thenApplyAsync(t -> (T)collector.finisher() + .apply(accumulator), + executor) + ); + } + else { + return CompletableFuture.completedStage(null); + } + } + ); } protected boolean isHeld() { diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ParameterizedOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ParameterizedOperation.java old mode 100644 new mode 100755 index 11b256b3..a4497613 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ParameterizedOperation.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ParameterizedOperation.java @@ -35,8 +35,8 @@ public abstract class ParameterizedOperation extends Operation protected final Map setParameters; protected CompletionStage futureParameters; - ParameterizedOperation(Connection conn, OperationGroup operationGroup) { - super(conn, operationGroup); + ParameterizedOperation(Session session, OperationGroup operationGroup) { + super(session, operationGroup); setParameters = new HashMap<>(); } diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/RowOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/RowOperation.java old mode 100644 new mode 100755 index fa94f11d..2de3f296 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/RowOperation.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/RowOperation.java @@ -16,7 +16,6 @@ package com.oracle.adbaoverjdbc; import jdk.incubator.sql2.ParameterizedRowOperation; -import jdk.incubator.sql2.Result; import jdk.incubator.sql2.SqlException; import jdk.incubator.sql2.SqlType; import java.sql.PreparedStatement; @@ -27,8 +26,11 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import java.util.concurrent.Executor; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; +import java.util.logging.Level; import java.util.stream.Collector; +import jdk.incubator.sql2.Result; /** * Creates separate CompletionStages to execute the query, to fetch and process @@ -47,8 +49,8 @@ class RowOperation extends ParameterizedOperation (a, v) -> {}, (a, b) -> null, a -> null); - static RowOperation newRowOperation(Connection conn, OperationGroup grp, String sql) { - return new RowOperation<>(conn, grp, sql); + static RowOperation newRowOperation(Session session, OperationGroup grp, String sql) { + return new RowOperation<>(session, grp, sql); } // attributes @@ -59,13 +61,14 @@ static RowOperation newRowOperation(Connection conn, OperationGroup grp, // internal state private PreparedStatement jdbcStatement; private ResultSet resultSet; + private ResultSetMetaData resultSetMetaData; private Object accumulator; private boolean rowsRemain; private long rowCount; private String[] identifiers; - protected RowOperation(Connection conn, OperationGroup grp, String sql) { - super(conn, grp); + protected RowOperation(Session session, OperationGroup grp, String sql) { + super(session, grp); fetchSize = NOT_SET; collector = DEFAULT_COLLECTOR; sqlString = sql; @@ -123,13 +126,14 @@ private void initFetchSize() throws SQLException { private void executeQuery() { checkCanceled(); try { - jdbcStatement = connection.prepareStatement(sqlString); + jdbcStatement = session.prepareStatement(sqlString); initFetchSize(); setParameters.forEach((String k, ParameterValue v) -> { v.set(jdbcStatement, k); }); - System.out.println("executeQuery(\"" + sqlString + "\")"); + group.logger.log(Level.FINE, () -> "executeQuery(\"" + sqlString + "\")"); resultSet = jdbcStatement.executeQuery(); + resultSetMetaData = resultSet.getMetaData(); accumulator = collector.supplier().get(); rowsRemain = true; rowCount = 0; @@ -164,7 +168,7 @@ private Object handleFetchRows() { private void handleRow() throws SQLException { checkCanceled(); - try (Row row = new Row(this)) { + try (RowColumn row = new RowOperation.RowColumn(this)) { collector.accumulator().accept(accumulator, row); } } @@ -187,12 +191,12 @@ private String[] getIdentifiers() { if (resultSet == null) { throw new IllegalStateException("TODO"); } - System.out.println("ResultSet.getMetaData()"); //DEBUG + group.logger.log(Level.FINE, () -> "ResultSet.getMetaData()"); //DEBUG ResultSetMetaData md = resultSet.getMetaData(); int count = md.getColumnCount(); identifiers = new String[count]; for (int i = 0; i < count; i++) { - identifiers[i] = md.getColumnName(i); + identifiers[i] = md.getColumnLabel(i + 1); } } catch (SQLException ex) { @@ -201,6 +205,15 @@ private String[] getIdentifiers() { } return identifiers; } + + String enquoteIdentifier(String id) { + try { + return jdbcStatement.enquoteIdentifier(id, false); + } + catch (SQLException ex) { + throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), sqlString, -1); + } + } @Override public ParameterizedRowOperation fetchSize(long rows) throws IllegalArgumentException { @@ -211,7 +224,7 @@ public ParameterizedRowOperation fetchSize(long rows) throws IllegalArgumentE } @Override - public ParameterizedRowOperation collect(Collector c) { + public ParameterizedRowOperation collect(Collector c) { if (isImmutable() || collector != DEFAULT_COLLECTOR) throw new IllegalStateException("TODO"); if (c == null) throw new IllegalArgumentException("TODO"); collector = c; @@ -249,45 +262,62 @@ public RowOperation set(String id, Object value) { return (RowOperation)super.set(id, value); } - static final class Row implements jdk.incubator.sql2.Result.Row, AutoCloseable { + static final class RowColumn implements jdk.incubator.sql2.Result.RowColumn, AutoCloseable { + + static RowOperation.RowColumn newRowColumn(RowOperation op) { + return new RowOperation.RowColumn(op); + } - private RowOperation op; + private final AtomicBoolean isClosed; // all slices and clones share this + private final RowOperation op; + private int columnIndex = -1; + private int columnOffset = 0; // used by slices + private int lastColumn = Integer.MAX_VALUE; - Row(RowOperation op) { + // use this only to construct de novo RowColumns. Do not use for slice or clone + // use clone() for that. + private RowColumn(RowOperation op) { + isClosed = new AtomicBoolean(false); this.op = op; + columnIndex = 1; + columnOffset = 0; + lastColumn = op.getIdentifiers().length + 1; + } + + /** make a clone into a slice + * + * @param numValues number of columns in the slice + * @return this RowColumn as a slice + */ + private RowColumn asSlice(int numValues) { + columnOffset = columnOffset + columnIndex; + columnIndex = 1; + lastColumn = numValues; + return this; } @Override public void close() { - op = null; + isClosed.set(true); } @Override public long rowNumber() { - if (op == null) throw new IllegalStateException("TODO"); + if (isClosed.get()) throw new IllegalStateException("TODO"); return op.rowCount; // keep an independent count because ResultSet.row is limited to int } @Override public void cancel() { - if (op == null) throw new IllegalStateException("TODO"); + if (isClosed.get()) throw new IllegalStateException("TODO"); throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override - public T get(String id, Class type) { - if (op == null) { - throw new IllegalStateException("TODO"); - } + public T get(Class type) { + if (isClosed.get()) throw new IllegalStateException("TODO"); try { - int index; - try { - index = Integer.parseInt(id); - } - catch (NumberFormatException ex) { - return op.resultSet.getObject(id, type); - } - return op.resultSet.getObject(index, type); + return op.resultSet.getObject(columnIndex + columnOffset, type); } catch (SQLException ex) { throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), op.sqlString, -1); @@ -295,10 +325,84 @@ public T get(String id, Class type) { } @Override - public String[] getIdentifiers() { - if (op == null) throw new IllegalStateException("TODO"); - return op.getIdentifiers(); + public String identifier() { + if (isClosed.get()) throw new IllegalStateException("TODO"); + return op.getIdentifiers()[columnIndex + columnOffset - 1]; + } + + @Override + public int index() { + if (isClosed.get()) throw new IllegalStateException("TODO"); + return columnIndex; + } + + @Override + public int absoluteIndex() { + if (isClosed.get()) throw new IllegalStateException("TODO"); + return columnIndex + columnOffset; + } + + @Override + public SqlType sqlType() { + if (isClosed.get()) throw new IllegalStateException("TODO"); + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public Class javaType() { + if (isClosed.get()) throw new IllegalStateException("TODO"); + return sqlType().getJavaType(); + } + + @Override + public long length() { + if (isClosed.get()) throw new IllegalStateException("TODO"); + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public int numberOfValuesRemaining() { + if (isClosed.get()) throw new IllegalStateException("TODO"); + return lastColumn - columnIndex; + } + + @Override + public Column at(String id) { + if (isClosed.get()) throw new IllegalStateException("TODO"); + String canonical = op.enquoteIdentifier(id); + String[] ids = op.getIdentifiers(); + int index = 1; + for(; index <= lastColumn && !ids[index + columnOffset - 1].equals(canonical); index++) { } + if (index > lastColumn) throw new IllegalArgumentException("TODO"); + else columnIndex = index; + return this; + } + + @Override + public Column at(int index) { + if (isClosed.get()) throw new IllegalStateException("TODO"); + if (index < 1 || lastColumn < index) throw new IllegalArgumentException("TODO"); + columnIndex = index; + return this; + } + + @Override + public RowColumn slice(int numValues) { + if (isClosed.get()) throw new IllegalStateException("TODO"); + return this.clone().asSlice(numValues); + } + + @Override + public RowOperation.RowColumn clone() { + if (isClosed.get()) throw new IllegalStateException("TODO"); + try { + return (RowOperation.RowColumn)super.clone(); + } + catch (CloneNotSupportedException ex) { + throw new RuntimeException("TODO", ex); + } } - } + } // RowColumn + } diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Connection.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Session.java old mode 100644 new mode 100755 similarity index 63% rename from java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Connection.java rename to java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Session.java index 342d821c..518c80dc --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Connection.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Session.java @@ -15,10 +15,11 @@ */ package com.oracle.adbaoverjdbc; -import jdk.incubator.sql2.AdbaConnectionProperty; -import jdk.incubator.sql2.Connection.Lifecycle; -import jdk.incubator.sql2.ConnectionProperty; +import jdk.incubator.sql2.AdbaSessionProperty; +import jdk.incubator.sql2.Session.Lifecycle; +import jdk.incubator.sql2.SessionProperty; import jdk.incubator.sql2.Operation; +import jdk.incubator.sql2.ParameterizedRowPublisherOperation; import jdk.incubator.sql2.ShardingKey; import jdk.incubator.sql2.SqlException; import jdk.incubator.sql2.TransactionOutcome; @@ -33,55 +34,57 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import java.util.concurrent.Executor; +import java.util.function.LongConsumer; +import java.util.logging.Level; /** - * Connection is a subclass of OperationGroup. The member Operation stuff is mostly + * Session is a subclass of OperationGroup. The member Operation stuff is mostly * inherited from OperationGroup. There are a couple of differences. First the - * predecessor for all Connections is an already completed CompletableFuture, - * ROOT. Since ROOT is completed a Connection will begin executing as soon as it - * is submitted. Second, a Connection is not really a member of an OperationGroup - * so the code that handles submitting the Connection is a little different from + * predecessor for all Sessions is an already completed CompletableFuture, + * ROOT. Since ROOT is completed a Session will begin executing as soon as it + * is submitted. Second, a Session is not really a member of an OperationGroup + * so the code that handles submitting the Session is a little different from * OperationGroup. * - * A Connection is also contains a java.sql.Connection and has methods to execute - * some JDBC actions. It might be a good idea to move the java.sql.Connection and + * A Session is also contains a java.sql.Session and has methods to execute + * some JDBC actions. It might be a good idea to move the java.sql.Session and * associated actions to a separate class. */ -class Connection extends OperationGroup implements jdk.incubator.sql2.Connection { +class Session extends OperationGroup implements jdk.incubator.sql2.Session { // STATIC protected static final CompletionStage ROOT = CompletableFuture.completedFuture(null); - static jdk.incubator.sql2.Connection newConnection(DataSource ds, - Map properties) { - return new Connection(ds, properties); + static jdk.incubator.sql2.Session newSession(DataSource ds, + Map properties) { + return new Session(ds, properties); } // FIELDS - private Lifecycle connectionLifecycle = Lifecycle.NEW; - private final Set lifecycleListeners; + private Lifecycle sessionLifecycle = Lifecycle.NEW; + private final Set lifecycleListeners; private final DataSource dataSource; - private final Map properties; + private final Map properties; private java.sql.Connection jdbcConnection; private final Executor executor; - private CompletableFuture connectionCF; + private CompletableFuture sessionCF; // CONSTRUCTORS - private Connection(DataSource ds, - Map properties) { - super(null, null); // hack as _this_ not allowed. See SimpleOperation constructor + private Session(DataSource ds, + Map properties) { + super(); this.lifecycleListeners = new HashSet<>(); dataSource = ds; this.properties = properties; - ConnectionProperty execProp = AdbaConnectionProperty.EXECUTOR; + SessionProperty execProp = AdbaSessionProperty.EXECUTOR; executor = (Executor) properties.getOrDefault(execProp, execProp.defaultValue()); } // PUBLIC @Override - public Operation connectOperation() { + public Operation attachOperation() { if (! isHeld()) { throw new IllegalStateException("TODO"); } @@ -113,16 +116,16 @@ public jdk.incubator.sql2.OperationGroup operationGroup() { } @Override - public Transaction transaction() { + public TransactionCompletion transactionCompletion() { if (! isHeld()) { throw new IllegalStateException("TODO"); } - return Transaction.createTransaction(this); + return TransactionCompletion.createTransaction(this); } @Override - public Connection registerLifecycleListener(ConnectionLifecycleListener listener) { - if (!connectionLifecycle.isActive()) { + public Session registerLifecycleListener(SessionLifecycleListener listener) { + if (!sessionLifecycle.isActive()) { throw new IllegalStateException("TODO"); } lifecycleListeners.add(listener); @@ -130,8 +133,8 @@ public Connection registerLifecycleListener(ConnectionLifecycleListener listener } @Override - public Connection deregisterLifecycleListener(ConnectionLifecycleListener listener) { - if (!connectionLifecycle.isActive()) { + public Session deregisterLifecycleListener(SessionLifecycleListener listener) { + if (!sessionLifecycle.isActive()) { throw new IllegalStateException("TODO"); } lifecycleListeners.remove(listener); @@ -139,20 +142,20 @@ public Connection deregisterLifecycleListener(ConnectionLifecycleListener listen } @Override - public Lifecycle getConnectionLifecycle() { - return connectionLifecycle; + public Lifecycle getSessionLifecycle() { + return sessionLifecycle; } @Override - public jdk.incubator.sql2.Connection abort() { - setLifecycle(connectionLifecycle.abort()); + public jdk.incubator.sql2.Session abort() { + setLifecycle(sessionLifecycle.abort()); this.closeImmediate(); return this; } @Override - public Map getProperties() { - Map map = new HashMap<>(properties.size()); + public Map getProperties() { + Map map = new HashMap<>(properties.size()); properties.forEach((k, v) -> { if (!k.isSensitive()) { map.put(k, v); @@ -167,43 +170,48 @@ public ShardingKey.Builder shardingKeyBuilder() { } @Override - public jdk.incubator.sql2.Connection activate() { - setLifecycle(connectionLifecycle.activate()); + public jdk.incubator.sql2.Session requestHook(LongConsumer request) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public jdk.incubator.sql2.Session activate() { + setLifecycle(sessionLifecycle.activate()); throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override - public jdk.incubator.sql2.Connection deactivate() { - setLifecycle(connectionLifecycle.deactivate()); + public jdk.incubator.sql2.Session deactivate() { + setLifecycle(sessionLifecycle.deactivate()); throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } - + // INTERNAL - protected Connection setLifecycle(Lifecycle next) { - Lifecycle previous = connectionLifecycle; - connectionLifecycle = next; + protected Session setLifecycle(Lifecycle next) { + Lifecycle previous = sessionLifecycle; + sessionLifecycle = next; if (previous != next) { lifecycleListeners.stream().forEach(l -> l.lifecycleEvent(this, previous, next)); } return this; } - Connection closeImmediate() { + Session closeImmediate() { try { if (jdbcConnection != null && !jdbcConnection.isClosed()) { - setLifecycle(connectionLifecycle.abort()); - jdbcConnection.abort(executor); // Connection.abort is not supposed to hang - //TODO should call connectionLifecycle.close() when abort completes. + setLifecycle(sessionLifecycle.abort()); + jdbcConnection.abort(executor); // Session.abort is not supposed to hang + //TODO should call sessionLifecycle.close() when abort completes. } } catch (SQLException ex) { throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); } finally { - dataSource.deregisterConnection(this); + dataSource.deregisterSession(this); } return this; } @@ -216,16 +224,16 @@ protected Executor getExecutor() { @Override jdk.incubator.sql2.Submission submit(com.oracle.adbaoverjdbc.Operation op) { if (op == this) { - // submitting the Connection OperationGroup - connectionCF = (CompletableFuture)attachErrorHandler(op.follows(ROOT, getExecutor())); - return com.oracle.adbaoverjdbc.Submission.submit(this::cancel, connectionCF); + // submitting the Session OperationGroup + sessionCF = (CompletableFuture)attachErrorHandler(op.follows(ROOT, getExecutor())); + return com.oracle.adbaoverjdbc.Submission.submit(this::cancel, sessionCF); } else { return super.submit(op); } } - protected V connectionPropertyValue(ConnectionProperty prop) { + protected V sessionPropertyValue(SessionProperty prop) { V value = (V)properties.get(prop); if (value == null) return (V)prop.defaultValue(); else return value; @@ -241,13 +249,14 @@ private Void jdbcConnect(com.oracle.adbaoverjdbc.Operation op) { Properties info = (Properties)properties.get(JdbcConnectionProperties.JDBC_CONNECTION_PROPERTIES); info = (Properties)(info == null ? JdbcConnectionProperties.JDBC_CONNECTION_PROPERTIES.defaultValue() : info.clone()); - info.setProperty("user", (String) properties.get(AdbaConnectionProperty.USER)); - info.setProperty("password", (String) properties.get(AdbaConnectionProperty.PASSWORD)); - String url = (String) properties.get(AdbaConnectionProperty.URL); - System.out.println("DriverManager.getConnection(\"" + url + "\", " + info +")"); //DEBUG + info.setProperty("user", (String) properties.get(AdbaSessionProperty.USER)); + info.setProperty("password", (String) properties.get(AdbaSessionProperty.PASSWORD)); + String url = (String) properties.get(AdbaSessionProperty.URL); + Properties p = info; + group.logger.log(Level.FINE, () -> "DriverManager.getSession(\"" + url + "\", " + p +")"); jdbcConnection = DriverManager.getConnection(url, info); jdbcConnection.setAutoCommit(false); - setLifecycle(Connection.Lifecycle.OPEN); + setLifecycle(Session.Lifecycle.OPEN); return null; } catch (SQLException ex) { @@ -262,7 +271,7 @@ private Void jdbcValidate(com.oracle.adbaoverjdbc.Operation op, case COMPLETE: case SERVER: int timeoutSeconds = (int) (op.getTimeoutMillis() / 1000L); - System.out.println("Connection.isValid(" + timeoutSeconds + ")"); //DEBUG + group.logger.log(Level.FINE, () -> "Session.isValid(" + timeoutSeconds + ")"); //DEBUG if (!jdbcConnection.isValid(timeoutSeconds)) { throw new SqlException("validation failure", null, null, -1, null, -1); } @@ -271,7 +280,7 @@ private Void jdbcValidate(com.oracle.adbaoverjdbc.Operation op, case SOCKET: case LOCAL: case NONE: - System.out.println("Connection.isClosed"); //DEBUG + group.logger.log(Level.FINE, () -> "Session.isClosed"); //DEBUG if (jdbcConnection.isClosed()) { throw new SqlException("validation failure", null, null, -1, null, -1); } @@ -288,7 +297,7 @@ protected T jdbcExecute(com.oracle.adbaoverjdbc.Operation op, String sql) try (java.sql.Statement stmt = jdbcConnection.createStatement()) { int timeoutSeconds = (int) (op.getTimeoutMillis() / 1000L); if (timeoutSeconds < 0) stmt.setQueryTimeout(timeoutSeconds); - System.out.println("Statement.execute(\"" + sql + "\")"); //DEBUG + group.logger.log(Level.FINE, () -> "Statement.execute(\"" + sql + "\")"); //DEBUG stmt.execute(sql); } catch (SQLException ex) { @@ -299,9 +308,9 @@ protected T jdbcExecute(com.oracle.adbaoverjdbc.Operation op, String sql) private Void jdbcClose(com.oracle.adbaoverjdbc.Operation op) { try { - setLifecycle(connectionLifecycle.close()); + setLifecycle(sessionLifecycle.close()); if (jdbcConnection != null) { - System.out.println("Connection.close"); //DEBUG + group.logger.log(Level.FINE, () -> "Session.close"); //DEBUG jdbcConnection.close(); } } @@ -310,25 +319,25 @@ private Void jdbcClose(com.oracle.adbaoverjdbc.Operation op) { } finally { closeImmediate(); - setLifecycle(connectionLifecycle.closed()); + setLifecycle(sessionLifecycle.closed()); } return null; } PreparedStatement prepareStatement(String sqlString) throws SQLException { - System.out.println("Connection.prepareStatement(\"" + sqlString + "\")"); //DEBUG + logger.log(Level.FINE, () -> "Session.prepareStatement(\"" + sqlString + "\")"); //DEBUG return jdbcConnection.prepareStatement(sqlString); } - TransactionOutcome jdbcEndTransaction(SimpleOperation op, Transaction trans) { + TransactionOutcome jdbcEndTransaction(SimpleOperation op, TransactionCompletion trans) { try { if (trans.endWithCommit(this)) { - System.out.println("commit"); //DEBUG + group.logger.log(Level.FINE, () -> "commit"); //DEBUG jdbcConnection.commit(); return TransactionOutcome.COMMIT; } else { - System.out.println("rollback"); //DEBUG + group.logger.log(Level.FINE, () -> "rollback"); //DEBUG jdbcConnection.rollback(); return TransactionOutcome.ROLLBACK; } @@ -337,5 +346,10 @@ TransactionOutcome jdbcEndTransaction(SimpleOperation op, Tr throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); } } - + + @Override + public ParameterizedRowPublisherOperation rowPublisherOperation(String sql) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + } diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ConnectionBuilder.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SessionBuilder.java old mode 100644 new mode 100755 similarity index 58% rename from java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ConnectionBuilder.java rename to java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SessionBuilder.java index 639fe58c..ed3b3063 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ConnectionBuilder.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SessionBuilder.java @@ -15,18 +15,18 @@ */ package com.oracle.adbaoverjdbc; -import jdk.incubator.sql2.ConnectionProperty; +import jdk.incubator.sql2.SessionProperty; import java.util.HashMap; import java.util.Map; /** - * A builder to create an AoJ connection. The AoJ connection creates a JDBC - * connection by calling java.sql.DriverManager.getConnection with the following - * user provided ConnectionProperty values: + * A builder to create an AoJ session. The AoJ session creates a JDBC + * Connection by calling {@link java.sql.DriverManager#getConnection} with the following + * user provided SessionProperty values: * *
*
URL
- *
passed as the url argument to getConnection
+ *
passed as the url argument to getSession
*
USER
*
added to the JDBC_CONNECTION_PROPERTIES as the "user" property.
*
PASSWORD
@@ -35,7 +35,7 @@ *
a java.util.Properties passed as the info argument to getConnection
*
*/ -class ConnectionBuilder implements jdk.incubator.sql2.Connection.Builder { +class SessionBuilder implements jdk.incubator.sql2.Session.Builder { /** * @@ -44,34 +44,34 @@ class ConnectionBuilder implements jdk.incubator.sql2.Connection.Builder { * @param requiredProperties. Captured * @return */ - static ConnectionBuilder newConnectionBuilder(DataSource ds, - Map defaultProperties, - Map requiredProperties) { - return new ConnectionBuilder(ds, defaultProperties, requiredProperties); + static SessionBuilder newSessionBuilder(DataSource ds, + Map defaultProperties, + Map requiredProperties) { + return new SessionBuilder(ds, defaultProperties, requiredProperties); } private boolean isBuilt = false; private final DataSource dataSource; - private final Map defaultProperties; - private final Map requiredProperties; + private final Map defaultProperties; + private final Map requiredProperties; /** * * @param ds - * @param defaultConnectionProperties - * @param specifiedConnectionProperties + * @param defaultSessionProperties + * @param specifiedSessionProperties */ - private ConnectionBuilder(DataSource ds, - Map defaultConnectionProperties, - Map specifiedConnectionProperties) { + private SessionBuilder(DataSource ds, + Map defaultSessionProperties, + Map specifiedSessionProperties) { super(); dataSource = ds; - defaultProperties = new HashMap(defaultConnectionProperties); - requiredProperties = new HashMap(specifiedConnectionProperties); + defaultProperties = new HashMap(defaultSessionProperties); + requiredProperties = new HashMap(specifiedSessionProperties); } @Override - public jdk.incubator.sql2.Connection.Builder property(ConnectionProperty property, Object value) { + public jdk.incubator.sql2.Session.Builder property(SessionProperty property, Object value) { if (isBuilt) { throw new IllegalStateException("TODO"); } @@ -86,7 +86,7 @@ public jdk.incubator.sql2.Connection.Builder property(ConnectionProperty propert } @Override - public jdk.incubator.sql2.Connection build() { + public jdk.incubator.sql2.Session build() { if (isBuilt) { throw new IllegalStateException("TODO"); } @@ -94,7 +94,7 @@ public jdk.incubator.sql2.Connection build() { // replace default values with specified values where provided // otherwise use defaults defaultProperties.putAll(requiredProperties); - return Connection.newConnection(dataSource, defaultProperties); + return Session.newSession(dataSource, defaultProperties); } } diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SimpleOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SimpleOperation.java old mode 100644 new mode 100755 index 64df935d..61cbc8e0 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SimpleOperation.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SimpleOperation.java @@ -27,18 +27,18 @@ */ class SimpleOperation extends Operation implements Supplier { - static SimpleOperation newOperation(Connection conn, + static SimpleOperation newOperation(Session session, OperationGroup group, Function, S> act) { - return new SimpleOperation<>(conn, group, act); + return new SimpleOperation<>(session, group, act); } private final Function, T> action; - protected SimpleOperation(Connection conn, + protected SimpleOperation(Session session, OperationGroup operationGroup, Function, T> act) { - super(conn, operationGroup); + super(session, operationGroup); action = act; } diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SqlOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SqlOperation.java old mode 100644 new mode 100755 index a606fbea..c27ba4cd --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SqlOperation.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SqlOperation.java @@ -20,11 +20,11 @@ */ class SqlOperation extends SimpleOperation { - static SqlOperation newOperation(Connection conn, OperationGroup group, String sql) { - return new SqlOperation<>(conn, group, sql); + static SqlOperation newOperation(Session session, OperationGroup group, String sql) { + return new SqlOperation<>(session, group, sql); } - protected SqlOperation(Connection conn, OperationGroup group, String sql) { - super(conn, group, op -> (T)conn.jdbcExecute(op, sql)); + protected SqlOperation(Session session, OperationGroup group, String sql) { + super(session, group, op -> (T)session.jdbcExecute(op, sql)); } } diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Submission.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Submission.java old mode 100644 new mode 100755 diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Transaction.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/TransactionEnd.java old mode 100644 new mode 100755 similarity index 70% rename from java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Transaction.java rename to java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/TransactionEnd.java index 98b14bce..17654f56 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Transaction.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/TransactionEnd.java @@ -18,27 +18,27 @@ /** * */ -class Transaction implements jdk.incubator.sql2.Transaction { +class TransactionCompletion implements jdk.incubator.sql2.TransactionCompletion { private boolean isRollbackOnly = false; private boolean isInFlight = true; - private final Connection connection; + private final Session session; - static Transaction createTransaction(Connection conn) { - return new Transaction(conn); + static TransactionCompletion createTransaction(Session session) { + return new TransactionCompletion(session); } - private Transaction(Connection conn) { - connection = conn; + private TransactionCompletion(Session session) { + this.session = session; } /** * - * @param conn + * @param session * @return true iff transaction should be committed. false otherwise */ - synchronized boolean endWithCommit(Connection conn) { - if (conn != connection) throw new IllegalArgumentException("TODO"); + synchronized boolean endWithCommit(Session session) { + if (session != session) throw new IllegalArgumentException("TODO"); if (!isInFlight) throw new IllegalStateException("TODO"); isInFlight = false; return !isRollbackOnly; @@ -46,7 +46,7 @@ synchronized boolean endWithCommit(Connection conn) { @Override public synchronized boolean setRollbackOnly() { - if (!connection.getConnectionLifecycle().isActive()) throw new IllegalStateException("TODO"); + if (!session.getSessionLifecycle().isActive()) throw new IllegalStateException("TODO"); if (isInFlight) { isRollbackOnly = true; return true; diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/UnskippableOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/UnskippableOperation.java old mode 100644 new mode 100755 index c56765be..73f43137 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/UnskippableOperation.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/UnskippableOperation.java @@ -24,16 +24,16 @@ */ class UnskippableOperation extends SimpleOperation { - static UnskippableOperation newOperation(Connection conn, + static UnskippableOperation newOperation(Session session, OperationGroup group, Function, S> action) { - return new UnskippableOperation<>(conn, group, action); + return new UnskippableOperation<>(session, group, action); } - protected UnskippableOperation(Connection conn, + protected UnskippableOperation(Session session, OperationGroup operationGroup, Function, T> action) { - super(conn, operationGroup, (Function, T>)action); + super(session, operationGroup, (Function, T>)action); } @Override diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/module-info.java b/java/AoJ/src/com/oracle/adbaoverjdbc/module-info.java old mode 100644 new mode 100755 diff --git a/java/AoJ/test/com/oracle/adbaoverjdbc/test/DataSourceFactoryTest.java b/java/AoJ/test/com/oracle/adbaoverjdbc/test/DataSourceFactoryTest.java new file mode 100755 index 00000000..446fd74e --- /dev/null +++ b/java/AoJ/test/com/oracle/adbaoverjdbc/test/DataSourceFactoryTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.oracle.adbaoverjdbc.test; + +import static com.oracle.adbaoverjdbc.test.TestConfig.*; +import static org.junit.Assert.*; +import org.junit.Test; + +import jdk.incubator.sql2.DataSource; +import jdk.incubator.sql2.DataSourceFactory; + +/** + * Verifies the public API of DataSourceFactory functions as described in the + * ADBA javadoc. + */ +public class DataSourceFactoryTest { + + /** + * Assert DataSourceFactory.newFactory(String) returns null if the input + * is not the name of a factory class. + */ + @Test + public void testNewFactoryNegative() { + DataSourceFactory factory = + DataSourceFactory.newFactory("NOT A FACTORY NAME"); + assertNull(factory); + } + + /** + * Assert DataSourceFactory.newFactory(String) returns a DataSourceFactory + * instance if the input is the name of a factory class. + */ + @Test + public void testNewFactory() { + DataSourceFactory factory = DataSourceFactory.newFactory(TEST_DS_FACTORY_NAME); + assertNotNull(factory); + assertEquals(TEST_DS_FACTORY_NAME, factory.getClass().getName()); + } + + /** + * Assert DataSourceFactory.builder() returns a DataSource.Builder instance. + */ + @Test + public void testBuilder() { + DataSourceFactory factory = DataSourceFactory.newFactory(TEST_DS_FACTORY_NAME); + DataSource.Builder builder = factory.builder(); + assertNotNull(builder); + } +} diff --git a/java/AoJ/test/com/oracle/adbaoverjdbc/test/DataSourceFactoryTest2.java b/java/AoJ/test/com/oracle/adbaoverjdbc/test/DataSourceFactoryTest2.java new file mode 100755 index 00000000..68476d12 --- /dev/null +++ b/java/AoJ/test/com/oracle/adbaoverjdbc/test/DataSourceFactoryTest2.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc.test; + +import jdk.incubator.sql2.DataSourceFactory; +import org.junit.Test; +import static org.junit.Assert.*; + +public class DataSourceFactoryTest2 { + + /** + * Verify that when DataSourceFactory name is null then it throws an + * exception. + */ + @Test + public void nullDataSourceFactory() { + try { + DataSourceFactory.newFactory(null); + } catch (IllegalArgumentException ex) { + // Exception expected + System.out.println(ex.getMessage()); + return; + } + + fail(); + } +} diff --git a/java/AoJ/test/com/oracle/adbaoverjdbc/test/DataSourceTest.java b/java/AoJ/test/com/oracle/adbaoverjdbc/test/DataSourceTest.java new file mode 100755 index 00000000..f583821a --- /dev/null +++ b/java/AoJ/test/com/oracle/adbaoverjdbc/test/DataSourceTest.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.oracle.adbaoverjdbc.test; + +import jdk.incubator.sql2.DataSourceFactory; + +import static com.oracle.adbaoverjdbc.test.TestConfig.*; + +/** + * Verifies the public API of DataSource functions as described in the ADBA + * javadoc. + */ +public class DataSourceTest { + + final DataSourceFactory dsFactory = + DataSourceFactory.newFactory(TEST_DS_FACTORY_NAME); + + + // Instances of this type are used to build DataSources. + // This type is immutable once configured. No property can be set more than once. + // No property can be set after build() is called. +} diff --git a/java/AoJ/test/com/oracle/adbaoverjdbc/test/FirstLight.java b/java/AoJ/test/com/oracle/adbaoverjdbc/test/FirstLight.java old mode 100644 new mode 100755 index b54254ec..9debe331 --- a/java/AoJ/test/com/oracle/adbaoverjdbc/test/FirstLight.java +++ b/java/AoJ/test/com/oracle/adbaoverjdbc/test/FirstLight.java @@ -16,12 +16,9 @@ package com.oracle.adbaoverjdbc.test; import jdk.incubator.sql2.AdbaType; -import jdk.incubator.sql2.Connection; import jdk.incubator.sql2.DataSourceFactory; import jdk.incubator.sql2.DataSource; -import jdk.incubator.sql2.Result; import jdk.incubator.sql2.SqlException; -import jdk.incubator.sql2.Transaction; import java.util.Properties; import java.util.concurrent.CompletionStage; import java.util.concurrent.ForkJoinPool; @@ -34,6 +31,9 @@ import org.junit.Test; import static org.junit.Assert.*; import static com.oracle.adbaoverjdbc.JdbcConnectionProperties.JDBC_CONNECTION_PROPERTIES; +import jdk.incubator.sql2.Result; +import jdk.incubator.sql2.Session; +import jdk.incubator.sql2.TransactionCompletion; /** * This is a quick and dirty test to check if anything at all is working. @@ -48,8 +48,8 @@ public class FirstLight { // // Define these three constants with the appropriate values for the database // and JDBC driver you want to use. Should work with ANY reasonably standard - // JDBC driver. These values are passed to DriverManager.getConnection. - public static final String URL = ""; + // JDBC driver. These values are passed to DriverManager.getSession. + public static final String URL = "jdbc:oracle:thin:@//den03cll.us.oracle.com:5521/main2.regress.rdbms.dev.us.oracle.com"; //""; public static final String USER = "scott"; //"; public static final String PASSWORD = "tiger"; //"; // Define this to be the most trivial SELECT possible @@ -83,16 +83,16 @@ public void tearDown() { @Test public void firstLight() { assertEquals("com.oracle.adbaoverjdbc.DataSourceFactory", - DataSourceFactory.forName(FACTORY_NAME).getClass().getName()); + DataSourceFactory.newFactory(FACTORY_NAME).getClass().getName()); } /** - * Verify that can create a DataSource, though not a Connection. Should work + * Verify that can create a DataSource, though not a Session. Should work * even if there is no database. */ @Test public void createDataSource() { - DataSourceFactory factory = DataSourceFactory.forName(FACTORY_NAME); + DataSourceFactory factory = DataSourceFactory.newFactory(FACTORY_NAME); DataSource ds = factory.builder() .url(URL) .username(USER) @@ -102,23 +102,23 @@ public void createDataSource() { } /** - * create a Connection and send a SQL to the database + * create a Session and send a SQL to the database */ @Test public void sqlOperation() { Properties props = new Properties(); props.setProperty("oracle.jdbc.implicitStatementCacheSize", "10"); - DataSourceFactory factory = DataSourceFactory.forName(FACTORY_NAME); + DataSourceFactory factory = DataSourceFactory.newFactory(FACTORY_NAME); DataSource ds = factory.builder() .url(URL) .username(USER) .password(PASSWORD) - .connectionProperty(JDBC_CONNECTION_PROPERTIES, props) + .sessionProperty(JDBC_CONNECTION_PROPERTIES, props) .build(); - Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.getMessage())); - try (conn) { - assertNotNull(conn); - conn.operation(TRIVIAL).submit(); + Session session = ds.getSession(t -> System.out.println("ERROR: " + t.getMessage())); + try (session) { + assertNotNull(session); + session.operation(TRIVIAL).submit(); } ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES); } @@ -130,27 +130,26 @@ public void sqlOperation() { public void rowOperation() { Properties props = new Properties(); props.setProperty("oracle.jdbc.implicitStatementCacheSize", "10"); - DataSourceFactory factory = DataSourceFactory.forName(FACTORY_NAME); + DataSourceFactory factory = DataSourceFactory.newFactory(FACTORY_NAME); try (DataSource ds = factory.builder() .url(URL) .username(USER) .password(PASSWORD) - .connectionProperty(JDBC_CONNECTION_PROPERTIES, props) + .sessionProperty(JDBC_CONNECTION_PROPERTIES, props) .build(); - Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.getMessage()))) { - assertNotNull(conn); - conn.rowOperation(TRIVIAL) + Session session = ds.getSession(t -> System.out.println("ERROR: " + t.getMessage()))) { + assertNotNull(session); + session.rowOperation(TRIVIAL) .collect(Collector.of(() -> null, (a, r) -> { - System.out.println("Trivial: " + r.get("1", String.class)); + System.out.println("Trivial: " + r.at(1).get(String.class)); }, (x, y) -> null)) .submit(); - conn.rowOperation("select * from emp") - .collect(Collector.of( - () -> new int[1], - (int[] a, Result.Row r) -> { - a[0] = a[0]+r.get("sal", Integer.class); + session.rowOperation("select * from emp") + .collect(Collector.of(() -> new int[1], + (int[] a, Result.RowColumn r) -> { + a[0] = a[0]+r.at("sal").get(Integer.class); }, (l, r) -> l, a -> (Integer)a[0])) @@ -158,12 +157,12 @@ public void rowOperation() { .getCompletionStage() .thenAccept( n -> {System.out.println("labor cost: " + n);}) .toCompletableFuture(); - conn.rowOperation("select * from emp where empno = ?") + session.rowOperation("select * from emp where empno = ?") .set("1", 7782) .collect(Collector.of( () -> null, (a, r) -> { - System.out.println("salary: $" + r.get("sal", Integer.class)); + System.out.println("salary: $" + r.at("sal").get(Integer.class)); }, (l, r) -> null)) .submit(); @@ -174,22 +173,22 @@ public void rowOperation() { /** * check does error handling do anything */ - @Test + //@Test public void errorHandling() { Properties props = new Properties(); props.setProperty("oracle.jdbc.implicitStatementCacheSize", "10"); - DataSourceFactory factory = DataSourceFactory.forName(FACTORY_NAME); + DataSourceFactory factory = DataSourceFactory.newFactory(FACTORY_NAME); try (DataSource ds = factory.builder() .url(URL) .username(USER) .password("invalid password") - .connectionProperty(JDBC_CONNECTION_PROPERTIES, props) + .sessionProperty(JDBC_CONNECTION_PROPERTIES, props) .build(); - Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.toString()))) { - conn.rowOperation(TRIVIAL) + Session session = ds.getSession(t -> System.out.println("ERROR: " + t.toString()))) { + session.rowOperation(TRIVIAL) .collect(Collector.of(() -> null, (a, r) -> { - System.out.println("Trivial: " + r.get("1", String.class)); + System.out.println("Trivial: " + r.at(1).get(String.class)); }, (x, y) -> null)) .onError( t -> { System.out.println(t.toString()); }) @@ -200,15 +199,15 @@ public void errorHandling() { .url(URL) .username(USER) .password(PASSWORD) - .connectionProperty(JDBC_CONNECTION_PROPERTIES, props) + .sessionProperty(JDBC_CONNECTION_PROPERTIES, props) .build(); - Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.toString()))) { - conn.rowOperation("select * from emp where empno = ?") + Session session = ds.getSession(t -> System.out.println("ERROR: " + t.toString()))) { + session.rowOperation("select * from emp where empno = ?") .set("1", 7782) .collect(Collector.of( () -> null, (a, r) -> { - System.out.println("salary: $" + r.get("sal", Integer.class)); + System.out.println("salary: $" + r.at("sal").get(Integer.class)); }, (l, r) -> null)) .onError( t -> { System.out.println(t.getMessage()); } ) @@ -219,33 +218,33 @@ public void errorHandling() { /** * Do something that approximates real work. Do a transaction. Uses - * Transaction, CompletionStage args, and catch Operation. + * TransactionCompletion, CompletionStage args, and catch Operation. */ @Test public void transaction() { Properties props = new Properties(); props.setProperty("oracle.jdbc.implicitStatementCacheSize", "10"); - DataSourceFactory factory = DataSourceFactory.forName(FACTORY_NAME); + DataSourceFactory factory = DataSourceFactory.newFactory(FACTORY_NAME); try (DataSource ds = factory.builder() .url(URL) .username(USER) .password(PASSWORD) - .connectionProperty(JDBC_CONNECTION_PROPERTIES, props) + .sessionProperty(JDBC_CONNECTION_PROPERTIES, props) .build(); - Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.toString()))) { - Transaction trans = conn.transaction(); - CompletionStage idF = conn.rowOperation("select empno, ename from emp where ename = ? for update") + Session session = ds.getSession(t -> System.out.println("ERROR: " + t.toString()))) { + TransactionCompletion trans = session.transactionCompletion(); + CompletionStage idF = session.rowOperation("select empno, ename from emp where ename = ? for update") .set("1", "CLARK", AdbaType.VARCHAR) .collect(Collector.of( () -> new int[1], - (a, r) -> {a[0] = r.get("empno", Integer.class); }, + (a, r) -> {a[0] = r.at("empno").get(Integer.class); }, (l, r) -> null, a -> a[0]) ) .submit() .getCompletionStage(); idF.thenAccept( id -> { System.out.println("id: " + id); } ); - conn.countOperation("update emp set deptno = ? where empno = ?") + session.rowCountOperation("update emp set deptno = ? where empno = ?") .set("1", 50, AdbaType.INTEGER) .set("2", idF, AdbaType.INTEGER) .apply(c -> { @@ -259,8 +258,8 @@ public void transaction() { .submit() .getCompletionStage() .thenAccept( c -> { System.out.println("updated rows: " + c); } ); - conn.catchErrors(); - conn.commitMaybeRollback(trans); + session.catchErrors(); + session.commitMaybeRollback(trans); } ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES); } diff --git a/java/AoJ/test/com/oracle/adbaoverjdbc/test/HelloWorld.java b/java/AoJ/test/com/oracle/adbaoverjdbc/test/HelloWorld.java new file mode 100755 index 00000000..a6e3e4c4 --- /dev/null +++ b/java/AoJ/test/com/oracle/adbaoverjdbc/test/HelloWorld.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc.test; + +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collector; +import jdk.incubator.sql2.DataSourceFactory; +import jdk.incubator.sql2.DataSource; +import org.junit.Test; +import jdk.incubator.sql2.Session; + +public class HelloWorld { + + public static final String URL = "jdbc:derby:memory:db;create=true"; + public static final String USER = "scott"; + public static final String PASSWORD = "tiger"; + public static final String FACTORY_NAME = "com.oracle.adbaoverjdbc.DataSourceFactory"; + + public static void main(String[] args) { + DataSourceFactory factory = DataSourceFactory.newFactory(FACTORY_NAME); + if (factory == null) { + System.err.println("Error: Could not get a DataSourceFactory!"); + } + else { + System.out.println("DataSourceFactory: " + factory); + try (DataSource ds = factory.builder() + .url(URL) + .username(USER) + .password(PASSWORD) + .build(); + Session session = ds.getSession()) { + System.out.println("Connected! DataSource: " + ds + " Session: " + session); + session.rowOperation("SELECT 1") + .collect(Collector.of(() -> null, + (a, r) -> { System.out.println(r.at(1).get(String.class)); }, + (l, r) -> null, + a -> {System.out.println("end"); return null; })) + .onError(ex -> { ex.printStackTrace(); }) + .submit(); + } + } + ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES); + } + + @Test + public void test() { + main(null); + } +} diff --git a/java/AoJ/test/com/oracle/adbaoverjdbc/test/NewEmptyJUnitTest.java b/java/AoJ/test/com/oracle/adbaoverjdbc/test/NewEmptyJUnitTest.java new file mode 100755 index 00000000..658e2f63 --- /dev/null +++ b/java/AoJ/test/com/oracle/adbaoverjdbc/test/NewEmptyJUnitTest.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc.test; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author douglas.surber + */ +public class NewEmptyJUnitTest { + + public NewEmptyJUnitTest() { + } + + @BeforeClass + public static void setUpClass() { + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + // TODO add test methods here. + // The methods must be annotated with annotation @Test. For example: + // + // @Test + // public void hello() {} +} diff --git a/java/AoJ/test/com/oracle/adbaoverjdbc/test/SessionPropertyTest.java b/java/AoJ/test/com/oracle/adbaoverjdbc/test/SessionPropertyTest.java new file mode 100755 index 00000000..810dd22b --- /dev/null +++ b/java/AoJ/test/com/oracle/adbaoverjdbc/test/SessionPropertyTest.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.oracle.adbaoverjdbc.test; + +import static jdk.incubator.sql2.AdbaSessionProperty.*; +import static org.junit.Assert.*; + +import java.util.Properties; + +import org.junit.Test; + +import com.oracle.adbaoverjdbc.JdbcConnectionProperties; + +import jdk.incubator.sql2.SessionProperty; + +/** + * Verifies the public API of SessionProperty functions as described in the + * ADBA javadoc. + */ +public class SessionPropertyTest { + + @Test + public void testUser() { + assertEquals("USER", USER.name()); + assertEquals(String.class, USER.range()); + assertFalse(USER.validate(1234)); + assertTrue(USER.validate("SCOTT")); + assertNull(USER.defaultValue()); + assertFalse(USER.isSensitive()); + } + + @Test + public void testPassword() { + assertEquals("PASSWORD", PASSWORD.name()); + assertEquals(String.class, PASSWORD.range()); + assertFalse(PASSWORD.validate(1234)); + assertTrue(PASSWORD.validate("tiger")); + assertNull(PASSWORD.defaultValue()); + assertTrue(PASSWORD.isSensitive()); + } + + @Test + public void testJdbcConnectionProperties() { + SessionProperty jdbcProps = + JdbcConnectionProperties.JDBC_CONNECTION_PROPERTIES; + + assertEquals("JDBC_CONNECTION_PROPERTIES", jdbcProps.name()); + assertEquals(Properties.class, jdbcProps.range()); + assertFalse(jdbcProps.validate(1234)); + assertTrue(jdbcProps.validate(new Properties())); + assertNotNull(jdbcProps.defaultValue()); + assertTrue(jdbcProps.validate(jdbcProps.defaultValue())); + + // Expect true because password is a JDBC connection property + assertTrue(jdbcProps.isSensitive()); + } + + // TODO: Test the configureOperation API +} diff --git a/java/AoJ/test/com/oracle/adbaoverjdbc/test/TestConfig.java b/java/AoJ/test/com/oracle/adbaoverjdbc/test/TestConfig.java new file mode 100755 index 00000000..dc98adb7 --- /dev/null +++ b/java/AoJ/test/com/oracle/adbaoverjdbc/test/TestConfig.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.oracle.adbaoverjdbc.test; + +public class TestConfig { + + static final String TEST_DS_FACTORY_NAME = + System.getProperty("test.DATA_SOURCE_FACTORY", + com.oracle.adbaoverjdbc.DataSourceFactory.class.getName()); + + static final String TEST_USER = System.getProperty("test.USER"); + + static final String TEST_PASSWORD = System.getProperty("test.PASSWORD"); + + static final String TEST_URL = System.getProperty("test.URL"); +} diff --git a/javascript/rest-api/part-4-handling-post-put-and-delete-requests/hr_app/db_apis/employees.js b/javascript/rest-api/part-4-handling-post-put-and-delete-requests/hr_app/db_apis/employees.js index 5e02d3f6..4bf56ef9 100644 --- a/javascript/rest-api/part-4-handling-post-put-and-delete-requests/hr_app/db_apis/employees.js +++ b/javascript/rest-api/part-4-handling-post-put-and-delete-requests/hr_app/db_apis/employees.js @@ -93,7 +93,7 @@ async function update(emp) { const employee = Object.assign({}, emp); const result = await database.simpleExecute(updateSql, employee); - if (result.rowsAffected === 1) { + if (result.rowsAffected && result.rowsAffected === 1) { return employee; } else { return null; diff --git a/optimizer/fine_grained/README.md b/optimizer/fine_grained/README.md new file mode 100644 index 00000000..0d76cd4c --- /dev/null +++ b/optimizer/fine_grained/README.md @@ -0,0 +1,26 @@ +This directory contains examples of fine-grained cursor invalidation. + +The 'tests.sql' script is provided to give you ideas on how to try this feature out for yourself. There is a spool file tests.lst if you want to look at expected output. + +The tests are in a raw state because I originally wrote the examples for my own benefit to explore the boundaries of this feature. In particular, there is a mixture of some DDL that *will* allow SQL statements to use rolling invalidation and some DDL that will not. There may be cases where a statement is accepted but it results in a no-op. Some of the PROMPT comments may be out of date because the test was created before Oracle Database 12c R2 was released. + +My intention is to tidy up these scripts for Oracle Database 18c but I hope you will find them interesting now. + +### Note + +The example was run on Oracle Database 12c Release 2. + +The tests are not intended to be 'full coverage' - there may be other cases that work. + +The test case drops tables T1 and T2. + +### DISCLAIMER + +* These scripts are provided for educational purposes only. +* They are NOT supported by Oracle World Wide Technical Support. +* The scripts have been tested and they appear to work as intended. +* You should always run scripts on a test instance. + +### WARNING + +* These scripts drop and create tables. For use on test databases diff --git a/optimizer/fine_grained/plan.sql b/optimizer/fine_grained/plan.sql new file mode 100644 index 00000000..eb92d5d0 --- /dev/null +++ b/optimizer/fine_grained/plan.sql @@ -0,0 +1,7 @@ +set linesize 200 +set tab off +set pagesize 1000 +column plan_table_output format a180 + +SELECT * +FROM table(DBMS_XPLAN.DISPLAY_CURSOR(FORMAT=>'TYPICAL')); diff --git a/optimizer/fine_grained/q.sql b/optimizer/fine_grained/q.sql new file mode 100644 index 00000000..586721ac --- /dev/null +++ b/optimizer/fine_grained/q.sql @@ -0,0 +1,27 @@ +alter system flush shared_pool; + +select /* TESTFG */ count(*) from t1 where id = 1; +@plan +select /* TESTFG */ count(*) from t1 where val1 = 1; +@plan +select /* TESTFG */ count(*) from t2 where id = 1; +@plan +select /* TESTFG */ count(*) from t2 where id = 1+150000; +@plan +select /* TESTFG */ count(*) from t2 where val1 = 1; +@plan +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t; +@plan +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1); +@plan +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50; +@plan +select /* TESTFG */ count(*) from t2 partition (p2); +@plan +select /* TESTFG */ count(*) from t2 partition (p1); +@plan +update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50; +update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50; +update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50; +update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50; +commit; diff --git a/optimizer/fine_grained/sql.sql b/optimizer/fine_grained/sql.sql new file mode 100644 index 00000000..5152824b --- /dev/null +++ b/optimizer/fine_grained/sql.sql @@ -0,0 +1,19 @@ +column EXACT_MATCHING_SIGNATURE format 99999999999999999999999999999999999 +set linesize 300 +set tab off +column sql_text format a85 +column is_shareable format a20 +column IS_ROLLING_INVALID format a20 +column IS_ROLLING_REFRESH_INVALID format a20 +column DDL_NO_INVALIDATE format a20 + +select sql_id,sql_text,child_number +, is_shareable, OBJECT_STATUS, INVALIDATIONS,IS_ROLLING_INVALID,IS_ROLLING_REFRESH_INVALID ,DDL_NO_INVALIDATE +from v$sql +where sql_text like '%TESTFG%' and sql_text not like '%v$sql%' +order by 2; + +select sql_id,is_shareable, IS_ROLLING_INVALID,IS_ROLLING_REFRESH_INVALID +from v$sql +where sql_text like '%TESTVG%' and sql_text not like '%v$sql%' +order by 2; diff --git a/optimizer/fine_grained/tab.sql b/optimizer/fine_grained/tab.sql new file mode 100644 index 00000000..a975e9d2 --- /dev/null +++ b/optimizer/fine_grained/tab.sql @@ -0,0 +1,32 @@ +drop table t1; +drop table t2; + +create table t1 (id number(10) not null, val1 number(10) not null, val2 number(10) not null); + +create table t2 (id number(10) not null, val1 number(10) not null, val2 number(10) not null) +partition by range (id) ( + partition p1 values less than (100000) +, partition p2 values less than (200000) +) +/ + +insert into t1 select rownum,rownum,rownum from ( +select 1 +from dual connect by rownum < 10000); + +insert into t2 select rownum,rownum,rownum from ( +select 1 +from dual connect by rownum < 10000); + +insert into t2 select rownum+100000,rownum,rownum from ( +select 1 +from dual connect by rownum < 10000); + + +create index t1i on t1 (id); +create index t2i on t2 (id) local ( +partition p1i, +partition p2i); + +exec dbms_stats.gather_table_stats(ownname=>user,tabname=>'t1'); +exec dbms_stats.gather_table_stats(ownname=>user,tabname=>'t2'); diff --git a/optimizer/fine_grained/tests.lst b/optimizer/fine_grained/tests.lst new file mode 100644 index 00000000..6ac4b717 --- /dev/null +++ b/optimizer/fine_grained/tests.lst @@ -0,0 +1,8381 @@ +SQL> @tests + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 1736604837 + +-------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +-------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 1 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | INDEX RANGE SCAN| T1I | 1 | 4 | 1 (0)| 00:00:01 | +-------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - access("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 1317774485 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 1 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 1 (0)| 00:00:01 | 1 | 1 | +|* 3 | INDEX RANGE SCAN | T2I | 1 | 4 | 1 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 1317774485 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 1 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 1 (0)| 00:00:01 | 2 | 2 | +|* 3 | INDEX RANGE SCAN | T2I | 1 | 5 | 1 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 682288026 + +------------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 2 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR | | 1000 | 5000 | 2 (0)| 00:00:01 | 1 | KEY | +|* 3 | INDEX RANGE SCAN | T2I | 1000 | 5000 | 2 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | INDEX FULL SCAN (MIN/MAX)| T1I | 1 | 4 | 2 (0)| 00:00:01 | | | +------------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 3928439236 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 8 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 8 (0)| 00:00:01 | 2 | 2 | +| 3 | INDEX FAST FULL SCAN | T2I | 9999 | 8 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 3928439236 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 7 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 7 (0)| 00:00:01 | 1 | 1 | +| 3 | INDEX FAST FULL SCAN | T2I | 9999 | 7 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- CREATE INDEX (visible) +SQL> -- +SQL> create index new1 on t1 (val2) deferred invalidation; + +Index created. + +SQL> create index new2 on t2 (val2) local deferred invalidation; + +Index created. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 Y N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 Y N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 Y N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 Y N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 Y N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 Y N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 Y N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 Y N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 Y N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 Y N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N + +14 rows selected. + + +no rows selected + +Press + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 1736604837 + +-------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +-------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 1 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | INDEX RANGE SCAN| T1I | 1 | 4 | 1 (0)| 00:00:01 | +-------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - access("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 1317774485 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 1 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 1 (0)| 00:00:01 | 1 | 1 | +|* 3 | INDEX RANGE SCAN | T2I | 1 | 4 | 1 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 1317774485 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 1 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 1 (0)| 00:00:01 | 2 | 2 | +|* 3 | INDEX RANGE SCAN | T2I | 1 | 5 | 1 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 682288026 + +------------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 2 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR | | 1000 | 5000 | 2 (0)| 00:00:01 | 1 | KEY | +|* 3 | INDEX RANGE SCAN | T2I | 1000 | 5000 | 2 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | INDEX FULL SCAN (MIN/MAX)| T1I | 1 | 4 | 2 (0)| 00:00:01 | | | +------------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 3928439236 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 8 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 8 (0)| 00:00:01 | 2 | 2 | +| 3 | INDEX FAST FULL SCAN | T2I | 9999 | 8 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 3928439236 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 7 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 7 (0)| 00:00:01 | 1 | 1 | +| 3 | INDEX FAST FULL SCAN | T2I | 9999 | 7 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- CREATE INDEX (invisible) +SQL> -- +SQL> create index new1 on t1 (val2) invisible deferred invalidation; + +Index created. + +SQL> create index new2 on t2 (val2) invisible local deferred invalidation; + +Index created. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 Y N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 Y N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 Y N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 Y N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 Y N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 Y N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 Y N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 Y N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 Y N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 Y N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N + +14 rows selected. + + +no rows selected + +Press + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 1736604837 + +-------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +-------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 1 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | INDEX RANGE SCAN| T1I | 1 | 4 | 1 (0)| 00:00:01 | +-------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - access("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 1317774485 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 1 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 1 (0)| 00:00:01 | 1 | 1 | +|* 3 | INDEX RANGE SCAN | T2I | 1 | 4 | 1 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 1317774485 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 1 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 1 (0)| 00:00:01 | 2 | 2 | +|* 3 | INDEX RANGE SCAN | T2I | 1 | 5 | 1 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 682288026 + +------------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 2 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR | | 1000 | 5000 | 2 (0)| 00:00:01 | 1 | KEY | +|* 3 | INDEX RANGE SCAN | T2I | 1000 | 5000 | 2 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | INDEX FULL SCAN (MIN/MAX)| T1I | 1 | 4 | 2 (0)| 00:00:01 | | | +------------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 3928439236 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 8 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 8 (0)| 00:00:01 | 2 | 2 | +| 3 | INDEX FAST FULL SCAN | T2I | 9999 | 8 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 3928439236 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 7 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 7 (0)| 00:00:01 | 1 | 1 | +| 3 | INDEX FAST FULL SCAN | T2I | 9999 | 7 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- DROP INDEX +SQL> -- +SQL> drop index t1i deferred invalidation; + +Index dropped. + +SQL> drop index t2i deferred invalidation; + +Index dropped. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 Y N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 Y N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y INVALID_UNAUTH 1 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 Y N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y INVALID_UNAUTH 1 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y INVALID_UNAUTH 1 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y INVALID_UNAUTH 1 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y INVALID_UNAUTH 1 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y INVALID_UNAUTH 1 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 Y N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N + +14 rows selected. + + +no rows selected + +Press + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 1736604837 + +-------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +-------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 1 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | INDEX RANGE SCAN| T1I | 1 | 4 | 1 (0)| 00:00:01 | +-------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - access("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 1317774485 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 1 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 1 (0)| 00:00:01 | 1 | 1 | +|* 3 | INDEX RANGE SCAN | T2I | 1 | 4 | 1 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 1317774485 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 1 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 1 (0)| 00:00:01 | 2 | 2 | +|* 3 | INDEX RANGE SCAN | T2I | 1 | 5 | 1 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 15 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 15 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 15 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 682288026 + +------------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 2 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR | | 1000 | 5000 | 2 (0)| 00:00:01 | 1 | KEY | +|* 3 | INDEX RANGE SCAN | T2I | 1000 | 5000 | 2 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | INDEX FULL SCAN (MIN/MAX)| T1I | 1 | 4 | 2 (0)| 00:00:01 | | | +------------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 3928439236 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 8 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 8 (0)| 00:00:01 | 2 | 2 | +| 3 | INDEX FAST FULL SCAN | T2I | 9999 | 8 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 3928439236 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 7 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 7 (0)| 00:00:01 | 1 | 1 | +| 3 | INDEX FAST FULL SCAN | T2I | 9999 | 7 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- INDEX UNUSABLE +SQL> -- +SQL> alter index t1i unusable deferred invalidation; + +Index altered. + +SQL> alter index t2i modify partition p1i unusable deferred invalidation; +alter index t2i modify partition p1i unusable deferred invalidation + * +ERROR at line 1: +ORA-14048: a partition maintenance operation may not be combined with other operations + + +SQL> +SQL> alter session set CURSOR_INVALIDATION = 'deferred'; + +Session altered. + +SQL> alter index t2i modify partition p1i unusable; + +Index altered. + +SQL> alter session set CURSOR_INVALIDATION = 'immediate'; + +Session altered. + +SQL> +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 Y N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 Y N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y INVALID_UNAUTH 1 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 Y N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y INVALID_UNAUTH 1 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y INVALID_UNAUTH 1 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y INVALID_UNAUTH 1 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y INVALID_UNAUTH 1 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y INVALID_UNAUTH 1 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y INVALID_UNAUTH 1 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N + +14 rows selected. + + +no rows selected + +Press + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 1736604837 + +-------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +-------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 1 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | INDEX RANGE SCAN| T1I | 1 | 4 | 1 (0)| 00:00:01 | +-------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - access("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 8 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 8 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 1317774485 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 1 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 1 (0)| 00:00:01 | 1 | 1 | +|* 3 | INDEX RANGE SCAN | T2I | 1 | 4 | 1 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 1317774485 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 1 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 1 (0)| 00:00:01 | 2 | 2 | +|* 3 | INDEX RANGE SCAN | T2I | 1 | 5 | 1 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 8 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 8 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 682288026 + +------------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 2 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR | | 1000 | 5000 | 2 (0)| 00:00:01 | 1 | KEY | +|* 3 | INDEX RANGE SCAN | T2I | 1000 | 5000 | 2 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | INDEX FULL SCAN (MIN/MAX)| T1I | 1 | 4 | 2 (0)| 00:00:01 | | | +------------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 8 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 8 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 3928439236 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 8 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 8 (0)| 00:00:01 | 2 | 2 | +| 3 | INDEX FAST FULL SCAN | T2I | 9999 | 8 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 3928439236 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 7 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 7 (0)| 00:00:01 | 1 | 1 | +| 3 | INDEX FAST FULL SCAN | T2I | 9999 | 7 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- INDEX REBUILD +SQL> -- +SQL> alter index t1i rebuild deferred invalidation; + +Index altered. + +SQL> alter index t2i rebuild partition p1i deferred invalidation; + +Index altered. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 Y N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 Y N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N Y N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 Y N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N Y N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N Y N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N Y N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N Y N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N Y N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N Y +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N Y N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N Y N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N Y N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N Y N + +14 rows selected. + + +no rows selected + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + +Get rid of indexes... +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- TRUNCATE TABLE/PARTITION +SQL> -- +SQL> -- ## NOTE Accepted but might not implemented because T1 is not partitioned... +SQL> truncate table t1 deferred invalidation; + +Table truncated. + +SQL> alter table t2 truncate partition p1 deferred invalidation; + +Table truncated. + +SQL> set echo off +### Truncate partition is fine-grained, but truncate table is not + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y INVALID_UNAUTH 1 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y INVALID_UNAUTH 1 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y INVALID_UNAUTH 1 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y INVALID_UNAUTH 1 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N Y N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N Y N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y INVALID_UNAUTH 1 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N Y N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N Y N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N Y N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N Y N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N Y N + +14 rows selected. + + +no rows selected + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + +Get rid of indexes... +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- MOVE TABLE/PARTITION +SQL> -- +SQL> -- ## NOTE Accepted but might not implemented... +SQL> alter table t1 move deferred invalidation; + +Table altered. + +SQL> alter table t2 move partition p1 deferred invalidation; + +Table altered. + +SQL> set echo off +### Truncate partition is fine-grained, but truncate table is not + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y INVALID_UNAUTH 1 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y INVALID_UNAUTH 1 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y INVALID_UNAUTH 1 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y INVALID_UNAUTH 1 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N Y N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N Y N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y INVALID_UNAUTH 1 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N Y N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N Y N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N Y N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N Y N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N Y N + +14 rows selected. + + +no rows selected + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + +Get rid of indexes... +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- MOVE TABLE/PARTITION +SQL> -- +SQL> -- ## NOTE Accepted but might not be implemented... +SQL> alter table t1 move deferred invalidation; + +Table altered. + +SQL> alter table t2 move deferred invalidation; +alter table t2 move deferred invalidation + * +ERROR at line 1: +ORA-14511: cannot perform operation on a partitioned object + + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y INVALID_UNAUTH 1 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y INVALID_UNAUTH 1 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y INVALID_UNAUTH 1 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y INVALID_UNAUTH 1 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y INVALID_UNAUTH 1 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + +Get rid of indexes... +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- TRUNCATE NON-PARTITIONED VS PARTITIONED TABLE +SQL> -- +SQL> -- ## NOTE Accepted but might not implemented for non-partitioned table +SQL> truncate table t1 deferred invalidation; + +Table truncated. + +SQL> truncate table t2 deferred invalidation; + +Table truncated. + +SQL> set echo off +### Truncate partition is fine-grained, but truncate table is not + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y INVALID_UNAUTH 1 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y INVALID_UNAUTH 1 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y INVALID_UNAUTH 1 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y INVALID_UNAUTH 1 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N Y N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N Y N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y INVALID_UNAUTH 1 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N Y N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N Y N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N Y N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N Y N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N Y N + +14 rows selected. + + +no rows selected + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + +Get rid of indexes... +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- ADD PARTITION +SQL> -- +SQL> alter table t2 add partition p3 values less than (300000) deferred invalidation; + +Table altered. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N Y N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N Y N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N Y N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y INVALID_UNAUTH 1 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y INVALID_UNAUTH 1 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N Y N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N + +14 rows selected. + + +no rows selected + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + +Get rid of indexes... +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> alter table t2 add partition p3 values less than (300000); + +Table altered. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 8 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 8 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 8 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 15 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 15 (0)| 00:00:01 | 1 | 3 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 15 (0)| 00:00:01 | 1 | 3 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 8 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 8 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 8 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- DROP PARTITION +SQL> -- +SQL> alter table t2 drop partition p3 deferred invalidation; + +Table altered. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y INVALID_UNAUTH 1 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y INVALID_UNAUTH 1 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N Y N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y INVALID_UNAUTH 1 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y INVALID_UNAUTH 1 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N Y N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N Y N + +14 rows selected. + + +no rows selected + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + +Get rid of indexes... +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> alter table t2 add partition p3 values less than (300000); + +Table altered. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 3 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 3 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- SPLIT PARTITION +SQL> -- +SQL> alter table t2 split partition p1 at (50000) into (partition p1,partition p1a) deferred invalidation; + +Table altered. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y INVALID_UNAUTH 1 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y INVALID_UNAUTH 1 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N Y N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y INVALID_UNAUTH 1 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y INVALID_UNAUTH 1 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N Y N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N + +14 rows selected. + + +no rows selected + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + +Get rid of indexes... +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> alter table t2 add partition p3 values less than (300000); + +Table altered. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 3 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 3 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- MERGE PARTITION +SQL> -- Note: hash-ADD, COALESCE should behave in same way - not tested here +SQL> -- +SQL> alter table t2 merge partitions p2 to p3 into partition px deferred invalidation; + +Table altered. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y INVALID_UNAUTH 1 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y INVALID_UNAUTH 1 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N Y N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y INVALID_UNAUTH 1 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y INVALID_UNAUTH 1 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N Y N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N + +14 rows selected. + + +no rows selected + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + +Get rid of indexes... +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> alter table t2 add partition p3 values less than (300000); + +Table altered. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 3 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 3 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- SHRINK +SQL> -- +SQL> -- Probably fails... +SQL> alter table t2 shrink space deferred invalidation; +alter table t2 shrink space deferred invalidation + * +ERROR at line 1: +ORA-10630: Illegal syntax specified with SHRINK clause + + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + +Get rid of indexes... +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- ADD CONSTRAINT +SQL> -- +SQL> -- ## NOTE Accepted but might not be implemeted. +SQL> alter table t1 add constraint mypk1 primary key (id) deferred invalidation; + +Table altered. + +SQL> alter table t2 add constraint mypk2 primary key (id) deferred invalidation; + +Table altered. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y INVALID_UNAUTH 1 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y INVALID_UNAUTH 1 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y INVALID_UNAUTH 1 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y INVALID_UNAUTH 1 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y INVALID_UNAUTH 1 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y INVALID_UNAUTH 1 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y INVALID_UNAUTH 1 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y INVALID_UNAUTH 1 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y INVALID_UNAUTH 1 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y INVALID_UNAUTH 1 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N + +14 rows selected. + + +no rows selected + +SQL> -- ## NOTE Accepted but not not be implemeted. +SQL> alter table t1 drop constraint mypk1 deferred invalidation; + +Table altered. + +SQL> +SQL> set echo off + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + +rename +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 8 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 8 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 8 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 15 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 15 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 15 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 24 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 15 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 15 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 8 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 8 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 8 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> alter table t2 rename partition p2 to p2x deferred invalidation; +alter table t2 rename partition p2 to p2x deferred invalidation + * +ERROR at line 1: +ORA-14048: a partition maintenance operation may not be combined with other operations + + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> +SQL> @tab +SQL> drop table t1; + +Table dropped. + +SQL> drop table t2; + +Table dropped. + +SQL> +SQL> create table t1 (id number(10) not null, val1 number(10) not null, val2 number(10) not null); + +Table created. + +SQL> +SQL> create table t2 (id number(10) not null, val1 number(10) not null, val2 number(10) not null) + 2 partition by range (id) ( + 3 partition p1 values less than (100000) + 4 , partition p2 values less than (200000) + 5 ) + 6 / + +Table created. + +SQL> +SQL> insert into t1 select rownum,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> insert into t2 select rownum,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> insert into t2 select rownum+100000,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> +SQL> create index t1i on t1 (id); + +Index created. + +SQL> create index t2i on t2 (id) local ( + 2 partition p1i, + 3 partition p2i); + +Index created. + +SQL> +SQL> exec dbms_stats.gather_table_stats(ownname=>user,tabname=>'t1'); + +PL/SQL procedure successfully completed. + +SQL> exec dbms_stats.gather_table_stats(ownname=>user,tabname=>'t2'); + +PL/SQL procedure successfully completed. + +SQL> prompt rename +rename +SQL> set echo on +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> alter table t2 modify partition p2 read only deferred invalidation; + +Table altered. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N Y +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N Y +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N Y +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N Y +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N Y +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N Y +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N Y N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N Y N + +14 rows selected. + + +no rows selected + +SQL> +SQL> @tab +SQL> drop table t1; + +Table dropped. + +SQL> drop table t2; + +Table dropped. + +SQL> +SQL> create table t1 (id number(10) not null, val1 number(10) not null, val2 number(10) not null); + +Table created. + +SQL> +SQL> create table t2 (id number(10) not null, val1 number(10) not null, val2 number(10) not null) + 2 partition by range (id) ( + 3 partition p1 values less than (100000) + 4 , partition p2 values less than (200000) + 5 ) + 6 / + +Table created. + +SQL> +SQL> insert into t1 select rownum,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> insert into t2 select rownum,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> insert into t2 select rownum+100000,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> +SQL> create index t1i on t1 (id); + +Index created. + +SQL> create index t2i on t2 (id) local ( + 2 partition p1i, + 3 partition p2i); + +Index created. + +SQL> +SQL> exec dbms_stats.gather_table_stats(ownname=>user,tabname=>'t1'); + +PL/SQL procedure successfully completed. + +SQL> exec dbms_stats.gather_table_stats(ownname=>user,tabname=>'t2'); + +PL/SQL procedure successfully completed. + +SQL> prompt rename +rename +SQL> set echo on +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> alter table t1 parallel 4 deferred invalidation; + +Table altered. + +SQL> alter table t2 parallel 4 deferred invalidation; + +Table altered. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 Y N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 Y N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 Y N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 Y N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 Y N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 Y N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 Y N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 Y N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 Y N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 Y N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 Y N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 Y N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 Y N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 Y N N + +14 rows selected. + + +no rows selected + +SQL> +SQL> @tab +SQL> drop table t1; + +Table dropped. + +SQL> drop table t2; + +Table dropped. + +SQL> +SQL> create table t1 (id number(10) not null, val1 number(10) not null, val2 number(10) not null); + +Table created. + +SQL> +SQL> create table t2 (id number(10) not null, val1 number(10) not null, val2 number(10) not null) + 2 partition by range (id) ( + 3 partition p1 values less than (100000) + 4 , partition p2 values less than (200000) + 5 ) + 6 / + +Table created. + +SQL> +SQL> insert into t1 select rownum,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> insert into t2 select rownum,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> insert into t2 select rownum+100000,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> +SQL> create index t1i on t1 (id); + +Index created. + +SQL> create index t2i on t2 (id) local ( + 2 partition p1i, + 3 partition p2i); + +Index created. + +SQL> +SQL> exec dbms_stats.gather_table_stats(ownname=>user,tabname=>'t1'); + +PL/SQL procedure successfully completed. + +SQL> exec dbms_stats.gather_table_stats(ownname=>user,tabname=>'t2'); + +PL/SQL procedure successfully completed. + +SQL> prompt rename +rename +SQL> set echo on +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> alter table t1 read only deferred invalidation; + +Table altered. + +SQL> alter table t2 read only deferred invalidation; + +Table altered. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N Y +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N Y +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N Y +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N Y +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N Y +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N Y +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N Y +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N Y +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N Y +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N Y +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N Y N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N Y N + +14 rows selected. + + +no rows selected + +SQL> +SQL> @tab +SQL> drop table t1; + +Table dropped. + +SQL> drop table t2; + +Table dropped. + +SQL> +SQL> create table t1 (id number(10) not null, val1 number(10) not null, val2 number(10) not null); + +Table created. + +SQL> +SQL> create table t2 (id number(10) not null, val1 number(10) not null, val2 number(10) not null) + 2 partition by range (id) ( + 3 partition p1 values less than (100000) + 4 , partition p2 values less than (200000) + 5 ) + 6 / + +Table created. + +SQL> +SQL> insert into t1 select rownum,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> insert into t2 select rownum,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> insert into t2 select rownum+100000,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> +SQL> create index t1i on t1 (id); + +Index created. + +SQL> create index t2i on t2 (id) local ( + 2 partition p1i, + 3 partition p2i); + +Index created. + +SQL> +SQL> exec dbms_stats.gather_table_stats(ownname=>user,tabname=>'t1'); + +PL/SQL procedure successfully completed. + +SQL> exec dbms_stats.gather_table_stats(ownname=>user,tabname=>'t2'); + +PL/SQL procedure successfully completed. + +SQL> prompt rename +rename +SQL> set echo on +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> alter table t2 modify default attributes tablespace system deferred invalidation; + +Table altered. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N Y +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N Y +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N Y +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N Y +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N Y +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N Y +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N Y +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N Y + +14 rows selected. + + +no rows selected + +SQL> +SQL> +SQL> +SQL> +SQL> +SQL> diff --git a/optimizer/fine_grained/tests.sql b/optimizer/fine_grained/tests.sql new file mode 100644 index 00000000..86110db2 --- /dev/null +++ b/optimizer/fine_grained/tests.sql @@ -0,0 +1,339 @@ +set tab on +set trim on +@tab +@q +@sql +set echo on +-- +-- CREATE INDEX (visible) +-- +create index new1 on t1 (val2) deferred invalidation; +create index new2 on t2 (val2) local deferred invalidation; +set echo off +@sql + +pause Press + +@tab +@q +@sql +set echo on +-- +-- CREATE INDEX (invisible) +-- +create index new1 on t1 (val2) invisible deferred invalidation; +create index new2 on t2 (val2) invisible local deferred invalidation; +set echo off +@sql + +pause Press + +@tab +@q +@sql +set echo on +-- +-- DROP INDEX +-- +drop index t1i deferred invalidation; +drop index t2i deferred invalidation; +set echo off +@sql + +pause Press + +@tab +@q +@sql +set echo on +-- +-- INDEX UNUSABLE +-- +alter index t1i unusable deferred invalidation; +alter index t2i modify partition p1i unusable deferred invalidation; + +alter session set CURSOR_INVALIDATION = 'deferred'; +alter index t2i modify partition p1i unusable; +alter session set CURSOR_INVALIDATION = 'immediate'; + +set echo off +@sql + +pause Press + +@tab +@q +@sql +set echo on +-- +-- INDEX REBUILD +-- +alter index t1i rebuild deferred invalidation; +alter index t2i rebuild partition p1i deferred invalidation; +set echo off +@sql + + +@tab +prompt Get rid of indexes... +set echo on +drop index t1i; +drop index t2i; +set echo off +@q +@sql +set echo on +-- +-- TRUNCATE TABLE/PARTITION +-- +-- ## NOTE Accepted but might not implemented because T1 is not partitioned... +truncate table t1 deferred invalidation; +alter table t2 truncate partition p1 deferred invalidation; +set echo off +prompt ### Truncate partition is fine-grained, but truncate table is not +@sql + + + +@tab +prompt Get rid of indexes... +set echo on +drop index t1i; +drop index t2i; +set echo off +@q +@sql +set echo on +-- +-- MOVE TABLE/PARTITION +-- +-- ## NOTE Accepted but might not implemented... +alter table t1 move deferred invalidation; +alter table t2 move partition p1 deferred invalidation; +set echo off +prompt ### Truncate partition is fine-grained, but truncate table is not +@sql + + +@tab +prompt Get rid of indexes... +set echo on +drop index t1i; +drop index t2i; +set echo off +@q +@sql +set echo on +-- +-- MOVE TABLE/PARTITION +-- +-- ## NOTE Accepted but might not be implemented... +alter table t1 move deferred invalidation; +alter table t2 move deferred invalidation; +set echo off +@sql + + + +@tab +prompt Get rid of indexes... +set echo on +drop index t1i; +drop index t2i; +set echo off +@q +@sql +set echo on +-- +-- TRUNCATE NON-PARTITIONED VS PARTITIONED TABLE +-- +-- ## NOTE Accepted but might not implemented for non-partitioned table +truncate table t1 deferred invalidation; +truncate table t2 deferred invalidation; +set echo off +prompt ### Truncate partition is fine-grained, but truncate table is not +@sql + +@tab +prompt Get rid of indexes... +set echo on +drop index t1i; +drop index t2i; +set echo off +@q +@sql +set echo on +-- +-- ADD PARTITION +-- +alter table t2 add partition p3 values less than (300000) deferred invalidation; +set echo off +@sql + + +@tab +prompt Get rid of indexes... +set echo on +drop index t1i; +drop index t2i; +alter table t2 add partition p3 values less than (300000); +set echo off +@q +@sql +set echo on +-- +-- DROP PARTITION +-- +alter table t2 drop partition p3 deferred invalidation; +set echo off +@sql + + +@tab +prompt Get rid of indexes... +set echo on +drop index t1i; +drop index t2i; +alter table t2 add partition p3 values less than (300000); +set echo off +@q +@sql +set echo on +-- +-- SPLIT PARTITION +-- +alter table t2 split partition p1 at (50000) into (partition p1,partition p1a) deferred invalidation; +set echo off +@sql + +@tab +prompt Get rid of indexes... +set echo on +drop index t1i; +drop index t2i; +alter table t2 add partition p3 values less than (300000); +set echo off +@q +@sql +set echo on +-- +-- MERGE PARTITION +-- Note: hash-ADD, COALESCE should behave in same way - not tested here +-- +alter table t2 merge partitions p2 to p3 into partition px deferred invalidation; +set echo off +@sql + +@tab +prompt Get rid of indexes... +set echo on +drop index t1i; +drop index t2i; +alter table t2 add partition p3 values less than (300000); +set echo off +@q +@sql +set echo on +-- +-- SHRINK +-- +-- Probably fails... +alter table t2 shrink space deferred invalidation; +set echo off +@sql + + +@tab +prompt Get rid of indexes... +set echo on +drop index t1i; +drop index t2i; +set echo off +@q +@sql +set echo on +-- +-- ADD CONSTRAINT +-- +-- ## NOTE Accepted but might not be implemeted. +alter table t1 add constraint mypk1 primary key (id) deferred invalidation; +alter table t2 add constraint mypk2 primary key (id) deferred invalidation; +set echo off +@sql +set echo on +-- ## NOTE Accepted but not not be implemeted. +alter table t1 drop constraint mypk1 deferred invalidation; + +set echo off + +@tab +prompt rename +set echo on +drop index t1i; +drop index t2i; +set echo off +@q +@sql +set echo on +alter table t2 rename partition p2 to p2x deferred invalidation; +set echo off +@sql +set echo on + +@tab +prompt rename +set echo on +drop index t1i; +drop index t2i; +set echo off +@q +@sql +set echo on +alter table t2 modify partition p2 read only deferred invalidation; +set echo off +@sql +set echo on + +@tab +prompt rename +set echo on +drop index t1i; +drop index t2i; +set echo off +@q +@sql +set echo on +alter table t1 parallel 4 deferred invalidation; +alter table t2 parallel 4 deferred invalidation; +set echo off +@sql +set echo on + +@tab +prompt rename +set echo on +drop index t1i; +drop index t2i; +set echo off +@q +@sql +set echo on +alter table t1 read only deferred invalidation; +alter table t2 read only deferred invalidation; +set echo off +@sql +set echo on + +@tab +prompt rename +set echo on +drop index t1i; +drop index t2i; +set echo off +@q +@sql +set echo on +alter table t2 modify default attributes tablespace system deferred invalidation; +set echo off +@sql +set echo on