Skip to content

Commit 53bae4a

Browse files
committed
CrateDB bulk operations: Add documentation
1 parent c7d4b3b commit 53bae4a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/connect.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,29 @@ method used.
221221
| | ``PDO::FETCH_OBJ`` |
222222
+----------------------------+-----------------------+
223223

224+
Bulk operations
225+
===============
226+
227+
With CrateDB :ref:`crate-reference:http-bulk-ops`, suitable for ``INSERT``,
228+
``UPDATE``, and ``DELETE`` statements, you can submit multiple records, aka.
229+
batches, to CrateDB within a single operation. By using this way of communication,
230+
both the client and the server will not waste resources on building and decoding
231+
huge SQL statements, and data will also propagate more efficiently between CrateDB
232+
cluster nodes.
233+
234+
To use this mode, the ``PDOStatement`` offers a corresponding ``bulkMode`` option.
235+
When creating a statement instance with it, the ``$parameters`` data will be
236+
obtained as a list of records, like demonstrated in the example below.
237+
238+
.. code-block:: php
239+
240+
$parameters = [[5, 'foo', 1], [6, 'bar', 2], [7, 'foo', 3], [8, 'bar', 4]];
241+
$statement = $connection->prepare(
242+
'INSERT INTO test_table (id, name, int_type) VALUES (?, ?, ?)',
243+
array("bulkMode" => true));
244+
$statement->execute($parameters);
245+
246+
224247
Next steps
225248
==========
226249

0 commit comments

Comments
 (0)