Skip to content

Commit 4001b93

Browse files
Doc improvements.
1 parent a692f74 commit 4001b93

File tree

6 files changed

+126
-50
lines changed

6 files changed

+126
-50
lines changed

doc/src/api_manual/async_cursor.rst

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -206,25 +206,25 @@ AsyncCursor Methods
206206
.. method:: AsyncCursor.fetchall()
207207

208208
Fetches all (remaining) rows of a query result, returning them as a list of
209-
tuples. An empty list is returned if no more rows are available. Note that
210-
the cursor's ``arraysize`` attribute can affect the performance of this
211-
operation, as internally reads from the database are done in batches
212-
corresponding to ``arraysize``.
209+
tuples. An empty list is returned if no more rows are available. An
210+
exception is raised if the previous call to :meth:`AsyncCursor.execute()`
211+
did not produce any result set or no call was issued yet.
213212

214-
An exception is raised if the previous call to
215-
:meth:`AsyncCursor.execute()` did not produce any result set or no call
216-
was issued yet.
213+
Note that the cursor's :attr:`~AsyncCursor.arraysize` attribute can affect
214+
the performance of this operation, as internally data is fetched in batches
215+
of that size from the database.
217216

218217
.. method:: AsyncCursor.fetchmany(size=cursor.arraysize)
219218

220219
Fetches the next set of rows of a query result, returning a list of tuples.
221220
An empty list is returned if no more rows are available. Note that the
222-
cursor's arraysize attribute can affect the performance of this operation.
221+
cursor's :attr:`~AsyncCursor.arraysize` attribute can affect the
222+
performance of this operation.
223223

224224
The number of rows to fetch is specified by the parameter. If it is not
225-
given, the cursor's arraysize attribute determines the number of rows to be
226-
fetched. If the number of rows available to be fetched is fewer than the
227-
amount requested, fewer rows will be returned.
225+
given, the cursor's :attr:`~AsyncCursor.arraysize` attribute determines the
226+
number of rows to be fetched. If the number of rows available to be fetched
227+
is fewer than the amount requested, fewer rows will be returned.
228228

229229
An exception is raised if the previous call to
230230
:meth:`AsyncCursor.execute()` did not produce any result set or no call
@@ -457,14 +457,15 @@ AsyncCursor Attributes
457457
the performance of a query since it directly affects the number of network
458458
round trips between Python and the database. For methods like
459459
:meth:`AsyncCursor.fetchone()` and :meth:`AsyncCursor.fetchall()` it
460-
does not change how many rows are returned to the application. For
461-
:meth:`AsyncCursor.fetchmany()` it is the default number of rows to fetch.
460+
affects internal behavior but does not change how many rows are returned to
461+
the application. For :meth:`AsyncCursor.fetchmany()` it is the default
462+
number of rows to fetch.
462463

463464
The attribute is only used for tuning row and SODA document fetches from
464465
the database. It does not affect data inserts.
465466

466-
Due to the performance benefits, the default ``Cursor.arraysize`` is *100*
467-
instead of the *1* that the Python DB API recommends.
467+
Due to the performance benefits, the default ``arraysize`` is *100* instead
468+
of the *1* that the Python DB API recommends.
468469

469470
See :ref:`Tuning Fetch Performance <tuningfetch>` for more information.
470471

doc/src/api_manual/cursor.rst

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -212,26 +212,28 @@ Cursor Methods
212212
.. method:: Cursor.fetchall()
213213

214214
Fetches all (remaining) rows of a query result, returning them as a list of
215-
tuples. An empty list is returned if no more rows are available. Note that
216-
the cursor's arraysize attribute can affect the performance of this
217-
operation, as internally reads from the database are done in batches
218-
corresponding to the arraysize.
215+
tuples. An empty list is returned if no more rows are available. An
216+
exception is raised if the previous call to :meth:`Cursor.execute()` did
217+
not produce any result set or no call was issued yet.
219218

220-
An exception is raised if the previous call to :meth:`Cursor.execute()`
221-
did not produce any result set or no call was issued yet.
219+
Note that the cursor's :attr:`~Cursor.arraysize` attribute can affect the
220+
performance of this operation, as internally data is fetched in batches of
221+
that size from the database. See :ref:`Tuning Fetch Performance
222+
<tuningfetch>`.
222223

223224
See :ref:`fetching` for an example.
224225

225226
.. method:: Cursor.fetchmany(size=cursor.arraysize)
226227

227228
Fetches the next set of rows of a query result, returning a list of tuples.
228229
An empty list is returned if no more rows are available. Note that the
229-
cursor's arraysize attribute can affect the performance of this operation.
230+
cursor's :attr:`~Cursor.arraysize` attribute can affect the performance of
231+
this operation.
230232

231233
The number of rows to fetch is specified by the parameter. If it is not
232-
given, the cursor's ``arraysize`` attribute determines the number of rows
233-
to be fetched. If the number of rows available to be fetched is fewer than
234-
the amount requested, fewer rows will be returned.
234+
given, the cursor's :attr:`~Cursor.arraysize` attribute determines the
235+
number of rows to be fetched. If the number of rows available to be fetched
236+
is fewer than the amount requested, fewer rows will be returned.
235237

236238
An exception is raised if the previous call to :meth:`Cursor.execute()`
237239
did not produce any result set or no call was issued yet.
@@ -480,15 +482,16 @@ Cursor Attributes
480482
from SELECT statements and REF CURSORS. The value can drastically affect
481483
the performance of a query since it directly affects the number of network
482484
round trips between Python and the database. For methods like
483-
:meth:`Cursor.fetchone()` and :meth:`Cursor.fetchall()` it does not change
484-
how many rows are returned to the application. For
485-
:meth:`Cursor.fetchmany()` it is the default number of rows to fetch.
485+
:meth:`Cursor.fetchone()` and :meth:`Cursor.fetchall()` it affects internal
486+
behavior but does not change how many rows are returned to the
487+
application. For :meth:`Cursor.fetchmany()` it is the default number of
488+
rows to fetch.
486489

487490
The attribute is only used for tuning row and SODA document fetches from
488491
the database. It does not affect data inserts.
489492

490-
Due to the performance benefits, the default ``Cursor.arraysize`` is *100*
491-
instead of the *1* that the Python DB API recommends.
493+
Due to the performance benefits, the default ``arraysize`` is *100* instead
494+
of the *1* that the Python DB API recommends.
492495

493496
See :ref:`Tuning Fetch Performance <tuningfetch>` for more information.
494497

doc/src/api_manual/module.rst

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,15 @@ Oracledb Methods
412412

413413
The ``pool_name`` parameter is expected to be a string which specifies the
414414
name of the pool when using multiple DRCP pools with Oracle Database 23.4
415-
or later. This value is used in both python-oracledb Thin and Thick modes.
416-
See :ref:`DRCP Pool Names <poolnames>`.
415+
or later. This parameter can be used in both python-oracledb Thin and Thick
416+
modes. However, in Thick mode, when the ``thick_mode_dsn_passthrough``
417+
value in effect is *True*, it can only be used if the ``dsn`` parameter is
418+
not specified. For Thick mode, you may prefer to set the Oracle Net
419+
Services parameter `POOL_NAME <https://www.oracle.com/pls/topic/lookup?ctx=
420+
dblatest&id=GUID-C2DA6A42-C30A-4E4C-9833-51CB383FE08B>`__ parameter in the
421+
:ref:`easy connect string <easyconnect>` or
422+
:ref:`connect descriptor <conndescriptor>`. See
423+
:ref:`DRCP Pool Names <poolnames>`.
417424

418425
If the ``handle`` parameter is specified, it must be of type OCISvcCtx\*
419426
and is only of use when embedding Python in an application (like
@@ -771,8 +778,15 @@ Oracledb Methods
771778

772779
The ``pool_name`` parameter is expected to be a string which specifies the
773780
name of the pool when using multiple DRCP pools with Oracle Database 23.4
774-
or later. This value is used in both python-oracledb Thin and Thick modes.
775-
See :ref:`DRCP Pool Names <poolnames>`.
781+
or later. This parameter can be used in both python-oracledb Thin and Thick
782+
modes. However, in Thick mode, when the ``thick_mode_dsn_passthrough``
783+
value in effect is *True*, it can only be used if the ``dsn`` parameter is
784+
not specified. For Thick mode, you may prefer to set the Oracle Net
785+
Services parameter `POOL_NAME <https://www.oracle.com/pls/topic/lookup?ctx=
786+
dblatest&id=GUID-C2DA6A42-C30A-4E4C-9833-51CB383FE08B>`__ parameter in the
787+
:ref:`easy connect string <easyconnect>` or
788+
:ref:`connect descriptor <conndescriptor>`. See
789+
:ref:`DRCP Pool Names <poolnames>`.
776790

777791
The ``thick_mode_dsn_passthrough`` and ``handle`` parameters are ignored in
778792
python-oracledb Thin mode.
@@ -1663,8 +1677,15 @@ Oracledb Methods
16631677

16641678
The ``pool_name`` parameter is expected to be a string which specifies the
16651679
name of the pool when using multiple DRCP pools with Oracle Database 23.4
1666-
or later. This value is used in both python-oracledb Thin and Thick modes.
1667-
See :ref:`DRCP Pool Names <poolnames>`.
1680+
or later. This parameter can be used in both python-oracledb Thin and Thick
1681+
modes. However, in Thick mode, when the ``thick_mode_dsn_passthrough``
1682+
value in effect is *True*, it can only be used if the ``dsn`` parameter is
1683+
not specified. For Thick mode, you may prefer to set the Oracle Net
1684+
Services parameter `POOL_NAME <https://www.oracle.com/pls/topic/lookup?ctx=
1685+
dblatest&id=GUID-C2DA6A42-C30A-4E4C-9833-51CB383FE08B>`__ parameter in the
1686+
:ref:`easy connect string <easyconnect>` or
1687+
:ref:`connect descriptor <conndescriptor>`. See
1688+
:ref:`DRCP Pool Names <poolnames>`.
16681689

16691690
If the ``handle`` parameter is specified, it must be of type OCISvcCtx\*
16701691
and is only of use when embedding Python in an application (like
@@ -2085,8 +2106,15 @@ Oracledb Methods
20852106

20862107
The ``pool_name`` parameter is expected to be a string which specifies the
20872108
name of the pool when using multiple DRCP pools with Oracle Database 23.4
2088-
or later. This value is used in both python-oracledb Thin and Thick modes.
2089-
See :ref:`DRCP Pool Names <poolnames>`.
2109+
or later. This parameter can be used in both python-oracledb Thin and Thick
2110+
modes. However, in Thick mode, when the ``thick_mode_dsn_passthrough``
2111+
value in effect is *True*, it can only be used if the ``dsn`` parameter is
2112+
not specified. For Thick mode, you may prefer to set the Oracle Net
2113+
Services parameter `POOL_NAME <https://www.oracle.com/pls/topic/lookup?ctx=
2114+
dblatest&id=GUID-C2DA6A42-C30A-4E4C-9833-51CB383FE08B>`__ parameter in the
2115+
:ref:`easy connect string <easyconnect>` or
2116+
:ref:`connect descriptor <conndescriptor>`. See
2117+
:ref:`DRCP Pool Names <poolnames>`.
20902118

20912119
The ``handle`` and ``thick_mode_dsn_passthrough`` parameters are ignored in
20922120
python-oracledb Thin mode.

doc/src/user_guide/appendix_b.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@ differs from the python-oracledb Thick mode in the following ways:
188188
* In python-oracledb Thin mode, the connection pool supports all the :ref:`connection
189189
mode privileges <connection-authorization-modes>`.
190190

191+
* In python-oracledb Thick mode, when the ``thick_mode_dsn_passthrough`` value
192+
in effect is *True*, the ``pool_name`` parameter can be used to specify a
193+
DRCP pool name only if the ``dsn`` parameter is not set. If both of these
194+
parameters are specified, then the ``pool_name`` parameter is ignored. In
195+
python-oracledb Thin mode, both of these parameters can be set and the value
196+
defined in the ``pool_name`` parameter will be used as the DRCP pool name.
197+
191198
Supported Database Data Types in Thin and Thick Modes
192199
=====================================================
193200

doc/src/user_guide/connection_handling.rst

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3115,9 +3115,9 @@ The overheads can impact ultimate scalability.
31153115
**DRCP Pool Names**
31163116

31173117
From Oracle Database 23ai, multiple DRCP pools can be created by setting a pool
3118-
name at DRCP pool creation time. Applications can then specifiy which DRCP pool
3119-
to use by passing the ``pool_name`` parameter during connection, or connection
3120-
pool, creation, for example:
3118+
name at DRCP pool creation time. Applications using python-oracledb Thin mode
3119+
can specify which DRCP pool to use by passing the ``pool_name`` parameter
3120+
during connection or connection pool creation, for example:
31213121

31223122
.. code-block:: python
31233123
@@ -3129,6 +3129,43 @@ pool, creation, for example:
31293129
When specifying a pool name, you should still set a connection class name to
31303130
allow efficient use of the pool's resources.
31313131

3132+
If you are using python-oracledb Thick mode and the
3133+
``thick_mode_dsn_passthrough`` value in effect is *True*, you can use the
3134+
``pool_name`` parameter only if the ``dsn`` parameter is not specified when
3135+
creating a standalone or pooled connection, for example:
3136+
3137+
.. code-block:: python
3138+
3139+
oracledb.init_oracle_client()
3140+
3141+
pool = oracledb.create_pool(user="hr", password=userpwd,
3142+
host="localhost", service_name="orclpdb",
3143+
server_type="pooled", min=2, max=5,
3144+
increment=1, cclass="MYAPP",
3145+
pool_name="MYPOOL")
3146+
3147+
If both the ``pool_name`` and ``dsn`` parameters are set when using Thick mode,
3148+
the ``pool_name`` parameter is ignored.
3149+
3150+
For Thick mode, you may prefer to set the Oracle Net
3151+
Services parameter `POOL_NAME <https://www.oracle.com/pls/topic/lookup?ctx=
3152+
dblatest&id=GUID-C2DA6A42-C30A-4E4C-9833-51CB383FE08B>`__ parameter in the
3153+
:ref:`easy connect string <easyconnect>` or
3154+
:ref:`connect descriptor <conndescriptor>`, for example:
3155+
3156+
.. code-block:: python
3157+
3158+
oracledb.init_oracle_client()
3159+
3160+
pool = oracledb.create_pool(user="hr", password=userpwd,
3161+
dsn="dbhost.example.com/orclpdb:pooled?pool_name=mypool",
3162+
min=2, max=5, increment=1,
3163+
cclass="MYAPP")
3164+
3165+
You can also define the DRCP pool name with the
3166+
:ref:`ConnectParams class <connparam>` when using python-oracledb Thin or Thick
3167+
mode. See :ref:`usingconnparams`.
3168+
31323169
**Acquiring a DRCP Connection**
31333170

31343171
Once DRCP has been enabled and the driver connection pool has been created with

doc/src/user_guide/tuning.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,15 @@ Some general tuning tips are:
7979
Tuning Fetch Performance
8080
========================
8181

82-
To tune queries, you can adjust python-oracledb's internal buffer sizes to
83-
improve the speed of fetching rows across the network from the database, and to
84-
optimize memory usage. This can reduce :ref:`round-trips <roundtrips>` which
85-
helps performance and scalability. Tune "array fetching" with
82+
To improve application performance and scalability you can adjust the sizes of
83+
python-oracledb's internal query result buffers. Increasing the buffers can
84+
reduce :ref:`round-trips <roundtrips>` to improve the overall speed of fetching
85+
rows across the network from the database. The buffer sizes can be used to tune
86+
the behavior of all python-oracledb :ref:`row fetching methods <fetching>` but
87+
do not affect how many rows are returned to your application by those methods.
88+
You should tune the buffers for optimal performance and memory usage.
89+
90+
Tune "array fetching" with
8691
:attr:`Cursor.arraysize` and tune "row prefetching" with
8792
:attr:`Cursor.prefetchrows`. Set these before calling
8893
:meth:`Cursor.execute()`. The value used for prefetching can also be set in an
@@ -92,11 +97,6 @@ separate, so increasing both settings will require more Python process memory.
9297
Queries that return LOBs and similar types will never prefetch rows, so the
9398
``prefetchrows`` value is ignored in those cases.
9499

95-
The internal buffer sizes do not affect how or when rows are returned to your
96-
application regardless of which :ref:`python-oracledb method <fetching>` is
97-
used to fetch query results. They do not affect the minimum or maximum number
98-
of rows returned by a query.
99-
100100
The difference between row prefetching and array fetching is when the internal
101101
buffering occurs. Internally python-oracledb performs separate "execute SQL
102102
statement" and "fetch data" steps. Prefetching allows query results to be

0 commit comments

Comments
 (0)