Articles

CockroachDB TIL : Vol. 12

Découvrez le dernier volume de CockroachDB TIL ! Apprenez-en plus sur les fonctionnalités et les améliorations de CockroachDB pour vous aider à développer des applications plus robustes.

Articles précédents

Volumes 1 à 11

Sujets

Le volume 1 à 11 de cet article traite de différents sujets liés au logiciel. Dans ce volume, nous allons examiner le sujet n°1 : Identifier les index partiels. Notre équipe d’ingénieurs a publié un avis technique #96924 indiquant que certains changements de schéma, tels que la suppression de colonnes référencées dans des index partiels, échoueront. Un client demande comment identifier les bases de données, les tables et les index partiels associés qui référencent les colonnes à supprimer. Les méthodes suivantes vont aider à trouver ces index indésirables.

En considérant une table avec les données suivantes :

Table: customers

Columns: id, name, address

Indexes:

CREATE INDEX customers_name_idx ON customers (name) WHERE address IS NOT NULL;

CREATE INDEX customers_address_idx ON customers (address) WHERE name IS NOT NULL;

La première méthode consiste à exécuter une requête SQL pour obtenir les informations sur les index partiels. La requête suivante peut être utilisée pour obtenir les informations sur les index partiels pour la table « customers » :

SELECT * FROM pg_indexes WHERE indpred IS NOT NULL AND tablename = ‘customers’;

Cette requête renvoie les informations sur les index partiels pour la table « customers ». Le résultat de cette requête est le suivant :

indexname | tablename | indpred

———-+———–+———

customers_name_idx | customers | (address IS NOT NULL)

customers_address_idx | customers | (name IS NOT NULL)

La deuxième méthode consiste à utiliser un outil logiciel pour identifier les index partiels. Il existe plusieurs outils logiciels qui peuvent être utilisés pour identifier les index partiels. Certains des outils logiciels populaires sont pg_indexes, pg_stat_user_indexes et pg_stat_all_indexes. Ces outils peuvent être utilisés pour obtenir des informations détaillées sur les index partiels d’une base de données. Ces outils peuvent également être utilisés pour obtenir des informations sur les index partiels pour une table spécifique.

Enfin, la troisième méthode consiste à utiliser le fichier de configuration du serveur PostgreSQL pour identifier les index partiels. Le fichier de configuration du serveur PostgreSQL contient des informations détaillées sur les index partiels. Ces informations peuvent être utilisées pour identifier les index partiels pour une base de données ou une table spécifique.

En conclusion, il existe plusieurs méthodes pour identifier les index partiels dans une base de données PostgreSQL. Ces méthodes peuvent être utilisées pour obtenir des informations détaillées sur les index partiels d’une base de données ou d’une table spécifique. Ces méthodes peuvent également être utilisées pour identifier les index partiels qui référencent des colonnes à supprimer.

Source de l’article sur DZONE

When it comes to managing multi-tenancy, there are a number of architectural routes you can take. A couple of the most popular are:

  1. Create a database per tenant.
  2. Use a single database but with tenant IDs to separate out data.

Both of these options have pros and cons, but getting into that is not the intention of this blog. Today we’ll be exploring what option 1 may look like on a single CockroachDB cluster.

Source de l’article sur DZONE


Motivation

In my previous article, I demonstrated how JWT tokens can replace passwords for a safer and more secure cloud-native future.

Check out my previous articles covering SSO for DB Console using Google OAuth, Microsoft Identity Platform, and Okta.

Source de l’article sur DZONE


Previous Articles

I’ve written about Presto and CockroachDB in the past, you may find the article below:

Data federation with CockroachDB and Presto

Source de l’article sur DZONE


Motivation

Once I completed my first two articles, I realized there are a lot of possibilities exposed by proxying MongoDB collections through FerretDB backed by CockroachDB. CockroachDB has unique data domiciling capabilities available through multi-region abstractions, inverted and partial indexes, computed columns and of course strong consistency. Today, we’re going to discuss unique constraints in MongoDB and CockroachDB.

High-level Steps

  • Start a 9-node multi-region cluster (CockroachDB Dedicated)
  • Start FerretDB (Docker)
  • Unique Indexes
  • Considerations
  • Conclusion

Step-by-step Instructions

Start a 9-Node Multi-region Cluster (Cockroachdb Dedicated)

I am going to use the same CockroachDB Dedicated cluster from the previous article. Please refer to the previous article for the detailed steps. You can get a 30-day trial of CockroachDB Dedicated following this link.

Source de l’article sur DZONE


Motivation

The problem this tutorial is trying to solve is the lack of a native Fivetran connector for CockroachDB. My customer has built their analytics pipeline based on Fivetran. Given there is no native integration, their next best guess was to set up a Postgres connector:

CockroachDB is PostgreSQL wire compatible, but it is not correct to assume it is 1:1. Let’s attempt to configure the connector:

Source de l’article sur DZONE

Given CockroachDB scales with vCPU, there’s a hard limit to how many active connections we can support per vCPU before a serious problem arises. PGBouncer stretches the limits a bit making it a cost-effective option. In serverless architectures, there is no client-side connection pooling, and using middleware like PGBouncer can alleviate the problem of connection storms. Please see my previous articles on the topic for more details.


Previous Articles

  1. Using PGBouncer with CockroachDB
  2. Using PGBouncer with Cockroach Cloud Free Tier
  3. Exploring PGBouncer auth_type(s) with CockroachDB

Motivation

We’ve covered how to deploy PGBouncer with a self-hosted CockroachDB cluster. Today, I’m going to demonstrate how to run PGBouncer along with the Cockroach Cloud free-forever tier database. The overall concepts are identical, but we will highlight some of the major differences in deploying PGBouncer with a cloud product.

Source de l’article sur DZONE

GSSAPI authentication is becoming increasingly popular as CockroachDB starting to make inroads in Fortune 2000 customer bases and financial services segment. That said, ecosystem coverage for GSS needs to improve for parity with other authN methods. Today, we are providing a workaround and a look at the future. By the way, do you realize this is my 15th article on Kerberos and CockroachDB?

Articles Covering CockroachDB and Kerberos

I find the topic of Kerberos very interesting and my colleagues commonly refer to me for help with this complex topic. I am by no means an expert at Kerberos, I am however familiar enough with it to be dangerous. That said, I’ve written multiple articles on the topic which you may find below:

Source de l’article sur DZONE


Motivation

I had a customer inquiring about whether CockroachDB is capable of working with multi-level JSON. Considering their JSON would have up to 3 levels of hierarchy, they wanted to know whether CockroachDB is able to use native capability to access data multiple levels down. This prompted my interest and led to this tutorial. Surprisingly, CockroachDB does not inhibit any limitations to the number of levels in hiearchy and performance can be improved using various optimizations also discussed below.

Start a Single Node Instance With Max SQL Memory Flag and Connect to It

Java

 

cockroach start-single-node --max-sql-memory=.25 --insecure --background
cockroach sql --insecure --host=localhost

Source de l’article sur DZONE

PGBouncer is a lightweight connection pooler for PostgreSQL. CockroachDB is a cloud-native SQL database for building global, scalable cloud services that survive disasters.

CockroachDB is a PostgreSQL wire compatible database, which means it aims to have tight compatibility with the PG ecosystem. Today, we’re going to wire PGBouncer to work with CockroachDB. This article is meant to scratch the surface of possibilities unblocked by PGBouncer with CockroachDB and not meant to be an in-depth overview. We’re currently researching this topic and will follow up with official docs on the proper architecture and sizing of PGBouncer and CockroachDB.

Source de l’article sur DZONE