sokrates > select distinct
sokrates > client_connection, client_oci_library, client_version, client_driver
sokrates > from v$session_connect_info
sokrates > where sid = (select sid from v$mystat where rownum=1)
sokrates > /
CLIENT_CONNEC CLIENT_OCI_LIBRARY CLIENT_VERSION CLIENT_DRIVER
------------- --------------------------- ---------------------------------------- ------------------------------
Heterogeneous Home-based 12.2.0.1.0 SQL*PLUS
sokrates > show parameter result
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
client_result_cache_lag big integer 60000
client_result_cache_size big integer 1G
result_cache_max_result integer 5
result_cache_max_size big integer 629152K
result_cache_mode string MANUAL
result_cache_remote_expiration integer 0
sokrates >
sokrates > create table t(i) result_cache(mode force) as select 1 from dual;
Table created.
sokrates > set autotr traceonly
sokrates > select * from t;
Execution Plan
----------------------------------------------------------
Plan hash value: 1601196873
-------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 3 | 2 (0)| 00:00:01 |
| 1 | RESULT CACHE | 0t0bmg4r2a06vd6wzxfsj5f5ud | | | | |
| 2 | TABLE ACCESS FULL| T | 1 | 3 | 2 (0)| 00:00:01 |
-------------------------------------------------------------------------------------------------
Result Cache Information (identified by operation id):
------------------------------------------------------
1 - column-count=1; dependencies=(SOKRATES.T); name="select * from t"
Statistics
----------------------------------------------------------
5 recursive calls
0 db block gets
5 consistent gets
1 physical reads
0 redo size
351 bytes sent via SQL*Net to client
500 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
Next call now should use client result cache, I would assume.
sokrates > /
Execution Plan
----------------------------------------------------------
Plan hash value: 1601196873
-------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 3 | 2 (0)| 00:00:01 |
| 1 | RESULT CACHE | 0t0bmg4r2a06vd6wzxfsj5f5ud | | | | |
| 2 | TABLE ACCESS FULL| T | 1 | 3 | 2 (0)| 00:00:01 |
-------------------------------------------------------------------------------------------------
Result Cache Information (identified by operation id):
------------------------------------------------------
1 - column-count=1; dependencies=(SOKRATES.T); name="select * from t"
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
351 bytes sent via SQL*Net to client
500 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
No, it didn't, I expected to see
0 SQL*Net roundtrips to/from clientsokrates > set autotr off
sokrates > select * from CLIENT_RESULT_CACHE_STATS$
sokrates > where cache_id in (select sid from v$mystat);
no rows selected
sokrates >
Why doesn't client result cache work here ?
How can I see "0 SQL*Net roundtrips to/from client" ?
Or is this feature not supported by sqlplus ?
note: I have
OCI_RESULT_CACHE_MAX_SIZE=1G
OCI_RESULT_CACHE_MAX_RSET_SIZE=10M
OCI_RESULT_CACHE_MAX_RSET_ROWS=20M
in my client-sqlnet.ora (is this even needed for client result cache ?)
Sorry for taking so long - I needed to do some research.
One of the prerequisites for client cache is statement caching, eg
SQL> create table t as select * from dba_objects;
Table created.
SQL> set feedback only
SQL> select * from t;
78257 rows selected.
SQL> set feedback on
SQL>
SQL> @mystat
Enter value for statname: SQL*Net
NAME VALUE
-------------------------------------------------- ----------
bytes sent via SQL*Net to client 12028716
bytes received via SQL*Net from client 114602
SQL*Net roundtrips to/from client 5248
bytes sent via SQL*Net to dblink 0
bytes received via SQL*Net from dblink 0
SQL*Net roundtrips to/from dblink 0
bytes via SQL*Net vector to client 0
bytes via SQL*Net vector from client 0
bytes via SQL*Net vector to dblink 0
bytes via SQL*Net vector from dblink 0
10 rows selected.
SQL>
SQL> set feedback only
SQL> select /*+ result_cache */ * from t;
78257 rows selected.
SQL> set feedback on
SQL> @mystat
Enter value for statname: SQL*Net
NAME VALUE
-------------------------------------------------- ----------
bytes sent via SQL*Net to client 24048365
bytes received via SQL*Net from client 219963
SQL*Net roundtrips to/from client 10469
bytes sent via SQL*Net to dblink 0
bytes received via SQL*Net from dblink 0
SQL*Net roundtrips to/from dblink 0
bytes via SQL*Net vector to client 0
bytes via SQL*Net vector from client 0
bytes via SQL*Net vector to dblink 0
bytes via SQL*Net vector from dblink 0
10 rows selected.
SQL>
SQL>
SQL> set feedback only
SQL> select /*+ result_cache */ * from t;
78257 rows selected.
SQL> set feedback on
SQL> @mystat
Enter value for statname: SQL*Net
NAME VALUE
-------------------------------------------------- ----------
bytes sent via SQL*Net to client 36068015
bytes received via SQL*Net from client 325233
SQL*Net roundtrips to/from client 15690
bytes sent via SQL*Net to dblink 0
bytes received via SQL*Net from dblink 0
SQL*Net roundtrips to/from dblink 0
bytes via SQL*Net vector to client 0
bytes via SQL*Net vector from client 0
bytes via SQL*Net vector to dblink 0
bytes via SQL*Net vector from dblink 0
10 rows selected.
<code>
So even with (server) result caching we see around 12megabytes across the network each call. Let us now turn on the statement cache
SQL>
SQL> set statementcache 50
SQL>
SQL> set feedback only
SQL> select /*+ result_cache */ * from t;
78257 rows selected.
SQL> set feedback on
SQL> @mystat
Enter value for statname: SQL*Net
NAME VALUE
-------------------------------------------------- ----------
bytes sent via SQL*Net to client 48087665
bytes received via SQL*Net from client 430571
SQL*Net roundtrips to/from client 20911
bytes sent via SQL*Net to dblink 0
bytes received via SQL*Net from dblink 0
SQL*Net roundtrips to/from dblink 0
bytes via SQL*Net vector to client 0
bytes via SQL*Net vector from client 0
bytes via SQL*Net vector to dblink 0
bytes via SQL*Net vector from dblink 0
10 rows selected.
SQL>
SQL> set feedback only
SQL> select /*+ result_cache */ * from t;
78257 rows selected.
SQL> set feedback on
SQL> @mystat
Enter value for statname: SQL*Net
NAME VALUE
-------------------------------------------------- ----------
bytes sent via SQL*Net to client 48088761
bytes received via SQL*Net from client 430619
SQL*Net roundtrips to/from client 20913
bytes sent via SQL*Net to dblink 0
bytes received via SQL*Net from dblink 0
SQL*Net roundtrips to/from dblink 0
bytes via SQL*Net vector to client 0
bytes via SQL*Net vector from client 0
bytes via SQL*Net vector to dblink 0
bytes via SQL*Net vector from dblink 0
10 rows selected.
SQL>
SQL>
And there you go !