Before you begin
Before reading this page, do the following:- or .
- .
- .
Your application should that can occur under .
Insert rows
When inserting multiple rows, a single is faster than multiple single-row statements.- (pgx)
- (JDBC)
- (psycopg3)
Bulk insert
If you need to get a lot of data into a CockroachDB cluster quickly, use the statement instead of sending SQL from application code. It will be much faster because it bypasses the SQL layer altogether and writes directly to the data store using low-level commands. For instructions, see the .Limit the size of rows
To help you avoid failures arising from misbehaving applications that bloat the size of rows, you can specify the behavior when a row or individual larger than a specified size is written to the database. Use thesql.guardrails.max_row_size_log to discover large rows and sql.guardrails.max_row_size_err to reject large rows.
When you write a row that exceeds sql.guardrails.max_row_size_log:
INSERT,UPSERT,UPDATE,CREATE TABLE AS,CREATE INDEX,ALTER TABLE,ALTER INDEX,IMPORT, orRESTOREstatements will log aLargeRowto the channel.SELECT,DELETE,TRUNCATE, andDROPare not affected.
sql.guardrails.max_row_size_err:
INSERT,UPSERT, andUPDATEstatements will fail with a code54000 (program_limit_exceeded)error.CREATE TABLE AS,CREATE INDEX,ALTER TABLE,ALTER INDEX,IMPORT, andRESTOREstatements will log aLargeRowInternalevent to the channel.SELECT,DELETE,TRUNCATE, andDROPare not affected.
sql.guardrails.max_row_size_log in conjunction with SELECT pg_column_size() queries to detect and fix any existing large rows before lowering sql.guardrails.max_row_size_err.

