<commit_before>.. _insert_performance:

==================
Insert Performance
==================

.. TIP::

   If ingestion performance is an important metric for you, and you can do your
   inserts in batches, you should switch from `Single Inserts`_ to `Bulk
   Inserts`_.

.. _single_inserts:

Single Inserts
==============

Single inserts (see :ref:`inserting_data` ) are typically very fast with
CrateDB. A small cluster can easily handle several thousand inserts per second
done this way.

However, single inserts generate a lot of internal network traffic, because
every insert is applied to the primary shard, and then individually
communicated in parallel to every configured replica shard. In addition,
CrateDB will not return a response to an insert request until all replica
shards have been updated.

If you can batch up your inserts, switching to `Bulk Inserts`_ will
dramatically improve ingestion performance.

.. _bulk_inserts:

Bulk Inserts
============

If you use the :ref:`sql_http_endpoint`, you can insert multiple records at
once by making use of :ref:`bulk_operations`. Our benchmarking_ indicates that
you can expect to see at least a twofold increase in ingestion performance.

.. _benchmarking: https://crate.io/a/insert-boost-on-replicas/<commit_msg>fixup! add insert performance docs<commit_after>.. _insert_performance:

==================
Insert Performance
==================

.. TIP::

   If ingestion performance is an important metric for you, and you can do your
   inserts in batches, you should switch from `Single Inserts`_ to `Bulk
   Inserts`_.

.. _single_inserts:

Single Inserts
==============

Single inserts (see :ref:`inserting_data` ) are typically very fast with
CrateDB. A small cluster can easily handle several thousand inserts per second
done this way.

However, single inserts generate a lot of internal network traffic, because
every insert is applied to the primary shard, and then individually
communicated in parallel to every configured replica shard. In addition,
CrateDB will not return a response to an insert request until all replica
shards have been updated.

If you can batch up your inserts, switching to `Bulk Inserts`_ will
dramatically improve ingestion performance.

.. _bulk_inserts:

Bulk Inserts
============

If you use the :ref:`sql_http_endpoint`, you can insert multiple records at
once by making use of :ref:`bulk_operations`. Our benchmarking_ indicates that
you can expect to see at least a twofold increase in ingestion performance.

Bulk inserts still generate internal network traffic, and CrateDB still waits
until all replicas have been updated before returning a response. But because
inserts are batched up, less internal communication and synchronisation is
needed.

.. _benchmarking: https://crate.io/a/insert-boost-on-replicas/
{'fraction_non_alphanumeric': 0.09187655196878326, 'fraction_numerical': 0.0, 'mean_word_length': 4.899581589958159, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4620722', 'n_tokens_mistral': 750, 'n_tokens_neox': 708, 'n_words': 361}