# This is an automatically generated code sample.
# To make this code sample work in your Oracle Cloud tenancy,
# please replace the values for any parameters whose current values do not fit
# your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
# boolean, number, and enum parameters with values not fitting your use case).

import oci
from datetime import datetime

# Create a default config using DEFAULT profile in default location
# Refer to
# https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File
# for more info
config = oci.config.from_file()


# Initialize service client with default config file
opsi_client = oci.opsi.OperationsInsightsClient(config)


# Send the request to service, some parameters are not required, see API
# doc for more info
ingest_sql_stats_response = opsi_client.ingest_sql_stats(
    ingest_sql_stats_details=oci.opsi.models.IngestSqlStatsDetails(
        items=[
            oci.opsi.models.SqlStats(
                sql_identifier="EXAMPLE-sqlIdentifier-Value",
                plan_hash_value=478,
                time_collected=datetime.strptime(
                    "2008-12-29T00:44:31.072Z",
                    "%Y-%m-%dT%H:%M:%S.%fZ"),
                instance_name="EXAMPLE-instanceName-Value",
                last_active_time="EXAMPLE-lastActiveTime-Value",
                parse_calls=396,
                disk_reads=289,
                direct_reads=144,
                direct_writes=675,
                buffer_gets=489,
                rows_processed=536,
                serializable_aborts=920,
                fetches=52,
                executions=61,
                avoided_executions=478,
                end_of_fetch_count=962,
                loads=609,
                version_count=343,
                invalidations=717,
                obsolete_count=55,
                px_servers_executions=976,
                cpu_time_in_us=692,
                elapsed_time_in_us=314,
                avg_hard_parse_time_in_us=273,
                concurrency_wait_time_in_us=699,
                application_wait_time_in_us=571,
                cluster_wait_time_in_us=163,
                user_io_wait_time_in_us=443,
                plsql_exec_time_in_us=464,
                java_exec_time_in_us=284,
                sorts=64,
                sharable_mem=797,
                total_sharable_mem=288,
                type_check_mem=883,
                io_cell_offload_eligible_bytes=539,
                io_interconnect_bytes=917,
                physical_read_requests=838,
                physical_read_bytes=526,
                physical_write_requests=678,
                physical_write_bytes=531,
                exact_matching_signature="EXAMPLE-exactMatchingSignature-Value",
                force_matching_signature="EXAMPLE-forceMatchingSignature-Value",
                io_cell_uncompressed_bytes=952,
                io_cell_offload_returned_bytes=845,
                child_number=214,
                command_type=65,
                users_opening=590,
                users_executing=549,
                optimizer_cost=558,
                full_plan_hash_value="EXAMPLE-fullPlanHashValue-Value",
                module="EXAMPLE-module-Value",
                service="EXAMPLE-service-Value",
                action="EXAMPLE-action-Value",
                sql_profile="EXAMPLE-sqlProfile-Value",
                sql_patch="EXAMPLE-sqlPatch-Value",
                sql_plan_baseline="EXAMPLE-sqlPlanBaseline-Value",
                delta_execution_count=97,
                delta_cpu_time=652,
                delta_io_bytes=566,
                delta_cpu_rank=781,
                delta_execs_rank=46,
                sharable_mem_rank=563,
                delta_io_rank=536,
                harmonic_sum=367,
                wt_harmonic_sum=463,
                total_sql_count=75)]),
    database_id="ocid1.test.oc1..<unique_ID>EXAMPLE-databaseId-Value",
    id="ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value",
    opc_request_id="KV3K5WGKWPZVWQS9IQMC<unique_ID>",
    if_match="EXAMPLE-ifMatch-Value",
    opc_retry_token="EXAMPLE-opcRetryToken-Value")

# Get the data from response
print(ingest_sql_stats_response.data)

Was this article helpful?