Category Archives: Databases

MySQL 5.7 alter table blocking operations

Table 14.12 Online DDL Support for Column Operations

MySQL: generate and insert a range of dummy rows

There are a lot of ways to do this, but the one below is the most straightforward to me.

How to safely update data in MySQL

Mock sql (sqlx) db on golang

I am using this library — https://pkg.go.dev/github.com/data-dog/go-sqlmock. That’s how you can use it for mocking db querying:

LSM-tree for write-intensive storages

LSM, or Log-structured Merge-Tree is used to improve the performance for write-intensive storages. 1. Writes are merged in memory using red-black tree, then flushed to disk sorted — SSTable or Sorted Strings Table. 2. For reads, we use Sparse Index to speed up the seeks, and Bloom Filter to speed up the non-present keys checks. …

Read more

Postgresql index naming convention

Use the table name as the prefix. Use the following suffixes: _pkey for a Primary Key constraint _key for a Unique constraint _excl for an Exclusion constraint _idx for any other kind of index _fkey for a Foreign key _check for a Check constraint https://stackoverflow.com/a/4108266/801426 Also implicitly mentioned here — https://www.postgresql.org/docs/current/sql-altertable.html

Postgresql exercises

Basic querying — https://pgexercises.com/questions/basic/. Joins — https://pgexercises.com/questions/joins/. Data modification — https://pgexercises.com/questions/updates/. Aggregations — https://pgexercises.com/questions/aggregates/. That could be useful to refresh your memory. Not really up-to-date, but still pretty useful.

How to start with google bigquery

Here is the list of thing I noticed when started to work with bigquery. First you need to create a project — https://cloud.google.com/bigquery/docs/quickstarts/quickstart-web-ui. That’s how you create a service key for bigquery — https://cloud.google.com/docs/authentication/getting-started. Select your project on the very top of the page, and then create JSON key. And don’t forget to set is …

Read more

Pros and cons of DynamoDB

What the author suggests is to use it in cases when there are not so many writes to DB and where eventual consistency is fine for the app. The writes are pretty expensive after all and could lead to problems with eventual consistency. And the main issue from my side is that DynamoDB is a …

Read more

How to choose a partition key for DynamoDB

Here’s an article about how to do it right: https://aws.amazon.com/blogs/database/choosing-the-right-dynamodb-partition-key/. The main ideas — partition key should have a good cardinality, but at the same time it should be queried easily as all the queries to DynamoDB should start with PartitionKey=…, as they are hashes.