Questions tagged [cockroachdb]

A scalable, geo-replicated, transactional SQL datastore developed in Go.

cockroachdb
Filter by
Sorted by
Tagged with
6 votes
2 answers
8k views

Can Go's Rows.Scan ignore fields from SQL query

The Rows.Scan method takes as many parameters as there are columns in the SQL query. As the query being executed is SHOW COLUMNS FROM my_table I cannot omit any column which I don't require (or can I?...
0 votes
1 answer
26 views

Does column order of multi-column primary keys matter in CockroachDB?

CRDB documentation for secondary indexes clearly states column order matters: Columns with a higher cardinality (higher number of distinct values) should be placed in the index before columns with a ...
0 votes
1 answer
64 views

CockroachDB: The best way to turn a UNIQUE CONSTRAINT into a PRIMARY KEY?

We have tables in CockroachDB which have a PK which always have 2 extra columns prefix, e.g. (u1, u2, id), now not needed anymore. For performance, there's also the real primary key set up as a UNIQUE ...
1 vote
1 answer
37 views

Is the ANY keyword in SQL considered an atomic operation?

I'm currently working on a project where I need to use the ANY keyword in a SQL query, and I'm curious about its atomicity. Specifically, I'm using it in the context of updating rows in a cockroachdb ...
1 vote
1 answer
2k views

Data migration from CockroachDB to PostgreSQL

I am trying to migrate my CockroachDB into PostgreSQL. I have dumps of CockroachDB data in SQL format like "booking.sql". I tried many ways ways to solve this problem: tried direct import ...
0 votes
0 answers
67 views

Cannot recover cockroachdb when a node is dead

I deploy cockroachdb helm chart (https://github.com/cockroachdb/helm-charts/tree/master) in my kubernetes cluster. Here is my value file. tls: enabled: false conf: join: - myapp-...
0 votes
1 answer
35 views

How to split table ranges to other nodes in a cluster

I have a write heavy table that will get write errors if all the table data is assigned to one range, so when I create the table, I want to split the table into multiple ranges assigned to different ...
0 votes
1 answer
32 views

Is there a limit on the table or database creation for CockroachDB Serverless

We know that CockroachDB Serverless provides auto-scaling for tenant, but is there a limit on the number of tables or databases that each tenant is allowed to create? Seems that the doc didn't ...
0 votes
0 answers
44 views

Using r2dbc-postgresql for CockroachDB result in authentication failure: "Password must not be null"

I'm trying to connect to a CockroachDB cluster using r2dbc-postgresql, (I've tried both org.postgresql as well as io.r2dbc) as well as spring-data-r2dbc from my reactive Kotlin app - which is running ...
0 votes
1 answer
41 views

Is it possible to perform evelope encryption in CockroachDB?

With Tink and AEAD I can perform envelope encryption in BigQuery. ref: https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#enveloping https://fuchsia.googlesource.com/third_party/tink/...
0 votes
0 answers
25 views

How to handle CA cert of Cockroach DB when deploying a Streamlit app to production?

I am trying to deploy a streamlit app to production that uses CockroachDB as the backend. To authenticate to CockroachDB, CA certs are needed in addition to the connection string credentials. How ...
0 votes
2 answers
498 views

How do I connect JetBrains DataGrip to CockroachDB Serverless?

I'd like to use JetBrains DataGrip with CockroachDB Serverless. How do I create a connection? I get errors that look like this: [08004] FATAL: codeParamsRoutingFailed: missing cluster name in ...
0 votes
1 answer
93 views

Error: P1001: Can't reach database server at `crdb`:`26257`

Framework:Nest js ORM: Prisma Database: Cockroach DB (like postgres) OS: Debian 12 I want to run a container using Docker Compose and am getting this error. Prisma schema loaded from prisma/schema....
3 votes
2 answers
573 views

Applying PRIMARY KEY constraint in CockroachDB - multiple primary keys error

I have created a table in CRDB without having any PRIMARY KEY and populated my data into the table. Now that the table is created and populated with data I want to apply a constraint to make the ...
0 votes
2 answers
881 views

How can I do the equivalent of ADD CONSTRAINT IF NOT EXISTS in cockroachdb/postgresql?

Most PostgreSQL statements support an IF NOT EXISTS clause to allow for idempotent migrations, e.g. CREATE TABLE IF NOT EXISTS foo .... But ALTER TABLE ... ADD CONSTRAINT doesn't. How can I write a ...
0 votes
1 answer
101 views

How does HLC hybrid logical clock solve Linearizability and Serializability in distributed transaction?

My understanding why distributed transaction need synchronized clock is the following true time = 100ms node A local time = 100ms node B local time = 0ms the following transaction will run into ...
0 votes
1 answer
91 views

Symfony database connection to CockroachDB

after several attempts I still don't understand what's happening, I'm trying to connect my database to a CockroachDB database, so I have this in my .env: DATABASE_URL=postgresql://user:password@...
2 votes
2 answers
84 views

Why is the slice not passed to the pg array?

I'm trying to pass a slice to a query that has a cte, but I get an error Goland code: insertQuery = ` WITH cte AS (SELECT $1 AS id, UNNEST(ARRAY($2)) AS address) ...
0 votes
1 answer
67 views

Using cockroachdb / postgresql in an iOS swift app

I'm trying to connect to a cockroachdb instance from within an iOS app being developed on Xcode. I am using the PostgresClientKit. I get an error saying: localizedSeverity: Fatal code: 0C800 message: ...
0 votes
1 answer
225 views

How to periodically delete data in CockroachDB

I am using CockroachDB for my newsletter project, and I want to delete rows every day when the data is unverified and the TTL stamp expired. It means it has to check both the "verified" ...
0 votes
1 answer
48 views

How to change my region on CockroachDB Cloud?

I'm currently in AWS us-west-2 and I'm trying to find a solution to change region to California — possibly Google Cloud — as I'm using CockroackDB Cloud I've been searching for a while. I have a small ...
0 votes
2 answers
335 views

Failure when running CockroachDB Helm Chart on Minikube: "Creating data directory: mkdir /cockroach/cockroach-data/auxiliary: permission denied"

When I try to run the cockroachdb on minikube v1.29.0 on Fedora 37 (selinux disabled) with default parameters, 2 of 3 nodes fails with the following error: Creating data directory: mkdir /cockroach/...
0 votes
2 answers
376 views

Why is method annotated with @PrePersist not called on @Entity class with @IdClass?

Why is method annotated with @PrePersist not called when persisting class annotated with @Entity and @IdClass? Folder (entity) @Data @Entity @NoArgsConstructor @AllArgsConstructor @Builder(toBuilder = ...
0 votes
1 answer
576 views

In Jetbrains Rider Datagrip, exporting database with pg_dump throws a search_path error

I have a CockroachDB cluster that i have connected to through JetBrains Rider. I want to make sure I can export all the data (as a backup, for example) using pg_dump. However, when running the export ...
1 vote
0 answers
81 views

How to ignore getaddrinfo ENOTFOUND in NestJS (using TypeORM)

We have a NestJS application which is using TypeORM for the database layer. We are doing a lot of requests to the database, sometimes the DB refuses the connection and even after some retries it ...
0 votes
1 answer
94 views

2 phase commit in CockroachDb

I don't want to write a long and complicated question. Is it possible to do 2 phase commits in CockroachDb natively similar to how it is done in Postgres? How do we do it in Postgres? PREPARE ...
3 votes
2 answers
2k views

Insert batch and Return full object using NamedParameterJdbcTemplate

I am trying to do batch insertion to a table and then read full objects back with their newly generated ids. private List<Customer> saveCustomer(List<Customer> customerList, Long ...
1 vote
2 answers
302 views

How to ensure uniqueness with NULL values in cockroach DB

I have a table of accounts which generates unique keys with a sequence. It is used to generate unique identities for accounts and account/user pairs. I tried the following from pgsql: CREATE INDEX ...
0 votes
1 answer
127 views

How can I update the statistics of a table in cockroachdb

In cockroachdb when I explain my query i see this root@:26257/management_console_production> explain select * from clusters; info --------------------------------...
1 vote
0 answers
61 views

The database session is not closed

When calling the SetPersonStatusByName function, a non-closing session occurs. Question: Did I miss anything to close the session after calling this function? func (m *DBManager) SetPersonStatusByName(...
0 votes
1 answer
813 views

How to connect to CockroachDB with docker-compose?

I have a docker-compose file in which I locally deploy the database and the application on go services: node_1: container_name: node_1 image: cockroachdb/cockroach:latest ...
3 votes
3 answers
677 views

Can we use PostgREST with CockroachDB

PostgREST serves a fully RESTful API from any existing PostgreSQL database. CockroachDB promises distributed SQL advantages. CockroachDB is built to be largely compatible with PostgreSQL. Here is a ...
0 votes
2 answers
257 views

CockroachDB equivalent of RowVersion in SQL

I'm trying to migrate my SQL db to CockroachDB. SQL Server has the RowVersion datatype which my database uses, which will automatically be generated every time a record is created, and then ...
0 votes
0 answers
64 views

Block size in Pebble storage engine

I'm using Pebble as the storage engine for one of my projects. My approach involves sequential reading from the Pebble DB. It's noticed that this process is typically constrained by the IOPS of the ...
0 votes
0 answers
46 views

How do I get psycopg_pool to connect to my Cockroach Database Cluster using psycog.crdb.connect which is supported in psycopg 3.1?

I'm using psycopg_pool (3.1.7) and would like to connect to a Cockroach Database Cluster. psycopg 3.1 has support for CRDB via psycopg.crdb.connect(), but I'm unsure how to get psycopg_pool to use ...
0 votes
0 answers
72 views

Networking issue between GCP instances - can't init Cockroach cluster

I deployed CockroachDB on Google Cloud Platform's Compute Engine using Terraform. I mainly followed the tutorial - Deploy CockroachDB on Google Cloud Platform GCE (Insecure). My issue is related to ...
1 vote
1 answer
176 views

Multi cluster CockroachDB with Cilium Cluster Mesh

I am trying to enable a multi cluster CockroachDB spawning 3 k8s clusters connected with Cilium Cluster Mesh. The idea of having a multi cluster CockroachDB is described on cockroachlabs.com - 1, 2. ...
0 votes
1 answer
468 views

"A PostgreSQL type with the name 'json' was not found in the database" - Npgsql & cochroach db

Using this code, A PostgreSQL type with the name 'json' was not found in the database Connection string var connString = "Host=REMOVE;Port=26257;Username=daniel;Password=REMOVED;Database=REMOVED&...
3 votes
0 answers
698 views

CockroachDB performance is much worse than mongoDB and Aurora?

I am doing some basic load testing against cockroachDB, mongoDB and Aurora. I just have a project which can keep read/write into one of those three DBs. In that project, we can configure groutine ...
1 vote
3 answers
541 views

Missing cluster identifier Error when connecting to serverless cockroachdb using the Python SQLmodel library

I have a python app which is using the SQLmodel library as an ORM wrapper. After successfully creating a database and multiple tables with sqlite3, I like to switch to cockroach db. Therefore I ...
2 votes
1 answer
664 views

keycloak and cockroachdb cloud

I tried to use keycloak db against crdb cloud. I have used https://github.com/codecentric/helm-charts/tree/master/charts/keycloak charts for deployment k8s. I create a db for the keycloak and give the ...
2 votes
1 answer
116 views

Does CockroachDB support read only mode?

Can you connect to CRDB in a read only mode? So that a connection cannot make any writes?
1 vote
1 answer
55 views

Kubernetes CockroachDB unable to access cluster externally

I installed cockroachdb via operator therefore used a kind: crdbcluster to spin up the cluster. Also using a metallb as loadbalancer. I'm trying to access a cockroachdb externally by exposing an ...
0 votes
2 answers
225 views

Kubernetes: Haproxy ingress isn't taking on any addresses

I'm running Kubernetes v1.25.9+rke2r1. I have a Metallb correctly setup with an external ip address and haproxy ingress controller. I need to expose a cockroachdb instance via ingress and I set up ...
0 votes
2 answers
918 views

sql: Delete oldest n records from each group

I'm using cockroachdb. For each group (grouped by id field), if the number of records exceeds 1000, I want to delete the oldest however_many records so that the number of records equal 1000 after the ...
0 votes
0 answers
32 views

How to Connect 2 Cockroachdb Cluster in Kubernetes

I have the following problem. In Kubernetes I have 2 clusters that I want to connect via Join. The clusters are running. The connection must be secure. I have created the CA of the old cluster. ...
0 votes
1 answer
39 views

How to create trigram index on json attribute in cockroachdb?

Is there a way to create trigram index on a json attribute in cockroach DB just like normal columns like CREATE INDEX ON t USING GIN (a, w gin_trgm_ops)?
0 votes
1 answer
103 views

DISTINCT on Two Individual Columns instead of Group of Two Columns

Table: Campaign_mapping campaign_id emailid_id 1 1 1 2 1 3 2 2 4 4 5 4 6 5 7 7 8 6 Table: Leads id campaign_id emailid_id data_a data_b data_c 2 1 a b c 3 2 2 a1 b2 c3 4 3 a2 b3 c4 5 ...
0 votes
1 answer
60 views

How to connect Heroku Discord Bot to CockroachDB?

I currently have a discord bot built with Nextcord.py with a working database on CockroachDB. I managed to host and deploy the bot on Heroku and commands work, but I can't seem to get the database to ...
2 votes
3 answers
2k views

Copying data from one CockroachDB cluster to another

I’m looking to copy the data from a production CockroachDB database to a development server. I know that in Postgres, I can directly connect the database servers through pg_dump and psql. What's the ...

1
2 3 4 5
10