Skip to content

Commit

Permalink
CrateDB bulk operations: Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed May 3, 2023
1 parent c7d4b3b commit 53bae4a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/connect.rst
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,29 @@ method used.
| | ``PDO::FETCH_OBJ`` |
+----------------------------+-----------------------+

Bulk operations
===============

With CrateDB :ref:`crate-reference:http-bulk-ops`, suitable for ``INSERT``,
``UPDATE``, and ``DELETE`` statements, you can submit multiple records, aka.
batches, to CrateDB within a single operation. By using this way of communication,
both the client and the server will not waste resources on building and decoding
huge SQL statements, and data will also propagate more efficiently between CrateDB
cluster nodes.

To use this mode, the ``PDOStatement`` offers a corresponding ``bulkMode`` option.
When creating a statement instance with it, the ``$parameters`` data will be
obtained as a list of records, like demonstrated in the example below.

.. code-block:: php
$parameters = [[5, 'foo', 1], [6, 'bar', 2], [7, 'foo', 3], [8, 'bar', 4]];
$statement = $connection->prepare(
'INSERT INTO test_table (id, name, int_type) VALUES (?, ?, ?)',
array("bulkMode" => true));
$statement->execute($parameters);
Next steps
==========

Expand Down

0 comments on commit 53bae4a

Please sign in to comment.