Pages

Monday, April 13, 2026

How to Use a PostgreSQL Generated Column for a Formatted Virtual Server SKU / Flavor

When designing a service catalog or virtual server definition table in PostgreSQL, it is common to need a derived attribute that is automatically generated from several existing columns.

A practical example is a virtual server flavor code (SKU - Stock Keeping Unit) derived from these attributes:

  • vserver_type – values such as ECONOMY, STANDARD, PREMIUM
  • num_of_vcpu – number of vCPUs, for example 1 to 64
  • capacity_of_vram – RAM size, for example 1 to 128

The requirement is to automatically generate a formatted code such as:

ECONOMY-04-016

In this format:

  • vserver_type is converted to uppercase
  • num_of_vcpu is formatted to 2 digits
  • capacity_of_vram is formatted to 3 digits
  • the delimiter is a hyphen (-)

Why use a generated column?

PostgreSQL generated columns are a clean solution for simple derived values. Instead of maintaining the derived attribute manually or using a trigger, PostgreSQL computes the value automatically from other columns in the same row.

This approach has several advantages:

  • the derived value is always consistent
  • there is no trigger logic to maintain
  • the column can still be indexed if needed
  • the formatting logic is centralized in the table definition

Final solution

CREATE TABLE vserver (
    vserver_type varchar(20),
    num_of_vcpu int,
    capacity_of_vram int,

    generated_code text GENERATED ALWAYS AS (
        upper(vserver_type) || '-' ||
        lpad(num_of_vcpu::text, 2, '0') || '-' ||
        lpad(capacity_of_vram::text, 3, '0')
    ) STORED
);

How it works

The generated column uses three PostgreSQL functions and operators:

  • upper(vserver_type) converts the server type to uppercase
  • lpad(num_of_vcpu::text, 2, '0') converts the vCPU count to text and left-pads it with zeros to a width of 2
  • lpad(capacity_of_vram::text, 3, '0') converts the RAM value to text and left-pads it with zeros to a width of 3
  • || concatenates the parts into a single string

So for example:

  • economy becomes ECONOMY
  • 4 becomes 04
  • 16 becomes 016

The final generated code is therefore:

ECONOMY-04-016

Example insert

INSERT INTO vserver (vserver_type, num_of_vcpu, capacity_of_vram)
VALUES ('economy', 4, 16);

If we query the table:

SELECT * FROM vserver;

The result will look like this:

 vserver_type | num_of_vcpu | capacity_of_vram | generated_code
--------------+-------------+------------------+----------------
 economy      |           4 |               16 | ECONOMY-04-016

More examples

STANDARD-01-008
PREMIUM-16-064
ECONOMY-64-128

Recommended validation

In production, it is a good idea to enforce valid input values with CHECK constraints.

CREATE TABLE vserver (
    vserver_type varchar(20),
    num_of_vcpu int,
    capacity_of_vram int,

    generated_code text GENERATED ALWAYS AS (
        upper(vserver_type) || '-' ||
        lpad(num_of_vcpu::text, 2, '0') || '-' ||
        lpad(capacity_of_vram::text, 3, '0')
    ) STORED,

    CHECK (vserver_type IN ('ECONOMY', 'STANDARD', 'PREMIUM')),
    CHECK (num_of_vcpu BETWEEN 1 AND 64),
    CHECK (capacity_of_vram BETWEEN 1 AND 128)
);

This ensures that:

  • only valid server types are accepted
  • vCPU count stays within the expected range
  • RAM capacity stays within the expected range

Why this pattern is useful

This pattern is useful for building a canonical service code or flavor identifier that is human-readable and deterministic. In infrastructure and cloud platforms, such a code can be reused across:

  • service catalogs
  • pricing definitions
  • provisioning logic
  • reporting and analytics
  • API output

Because the value is generated directly by PostgreSQL, applications do not need to duplicate the formatting logic.

Conclusion

If you need a simple derived value in PostgreSQL that depends only on other columns in the same row, a generated column is often the best solution.

In this example, PostgreSQL automatically creates a clean server code such as ECONOMY-04-016 from three separate attributes, without requiring triggers or procedural logic.

For straightforward formatting and deterministic derived values, this is usually the simplest and most maintainable approach.

Sunday, March 1, 2026

System Performance Benchmarks

In this blog post, I will list few performance benchmarks worth to run on the infrastructure systems to know how good the infrastructure is for particular application.

  • sysbench
  • fio
  • iperf
  • HammerDB
  • MLPerf 

Do you want to know more about each of these benchmarks? Keep reading the rest of this blog post.

Saturday, February 28, 2026

Benchmark of ImpossibleCloud S3 Object Storage (Prague <--> Frankfurt)

ImpossibleCloud (IC) S3 storage is pretty interesting offering of European Object Storage. Cloud4com datacenters are located in Czechia, Prague and closest IC S3 Storage is in Frankfurt. IC S3 Storage could be used for offsite backups or remote object repositories. Our primary use case is Off-Site Backup Repository.

In this blog post, I will do a benchmark of ImpossibleCloud S3 storage located in Frankfurt accessed from Prague's Cloud4com datacenter.

I have S3 client in Cloud4com vPDC in Prague and accessing ImpossibleCloud S3 Storage in Frankfurt.

Cloud4com physical datacenter is located at Prague, TTC

  • vRouter with Guaranteed bandwidth (CIR) 100 Mbps and Maximal bandwidth (Shaping) 1000 Mb/s
  • S3 Client (MinIO Warp) is running on VM (4 vCPU, 4 GB RAM, 1 Gb vNIC, 10 GB vSSD @ 500 IOPS) with FreeBSD 14.3

ImpossibleCloud S3 Storage is located at the “eu-central-2” region which corresponds to data centers in Germany (Europe / Frankfurt area).

Let's do some performance tests and report achieved results. 

Tuesday, February 10, 2026

Agile Project Management - INTRO [Czech Version]

Co je Agile Project Management a proč byste měli znát knihy The Phoenix Project a The Unicorn Project

Když se dnes řekne agilní projektové řízení, spousta lidí si představí Scrum meetingy, Kanban tabule a nekonečné množství nových buzzwordů. Jenže skutečný smysl agility je mnohem hlubší – jde o schopnost firmy rychle reagovat na změny, dodávat hodnotu zákazníkům a nebýt paralyzována vlastní byrokracií a procesy.

A právě tohle téma velmi dobře vysvětlují dvě knihy, které se staly doslova IT bestsellery:

Part #1 – The Phoenix Project
A Novel about IT, DevOps, and Helping Your Business Win

Part #2 – The Unicorn Project
A Novel about Developers, Digital Disruption, and Thriving in the Age of Data

Nejste v tom sami

Obě knihy formou příběhu ukazují realitu, ve které se dnes nachází většina středních a velkých firem. Neustálý tlak na rychlejší dodávky, hromadící se technický dluh, přetížené IT týmy, nekonečné priority „na včera“ a pocit, že systém je tak složitý, že už ho nikdo plně nechápe.

To nejdůležitější poselství je ale uklidňující:

Nejste jediní, kdo je v takové situaci. 

V podobném chaosu funguje obrovské množství organizací po celém světě.

Právě proto se z těchto knih stal fenomén. Lidé v nich poznávají vlastní každodenní realitu – jen je podaná zábavnou a srozumitelnou formou.

Chcete vědět více? Tak čtěte dále ...

Agile Project Management - Types of Work Packages

When you need to managed project in the agile way. You must know the terminology.

In this blog post we define meaning of general types of Work Packages:

  • Task
  • Milestone
  • Summary Task
  • Feature
  • Epic
  • User Story
  • Bug 

Types of Work Packages in OpenProject tool

If you do not know OpenProject.org watch tutorial on YouTube ...


To know more about types of work, read more ...

Sunday, February 1, 2026

Platform Engineering - SLA vs SLO & Platform Org Chart

When building and operating platform services—whether it’s cloud hosting, APIs, or IT support—you’ll often hear the terms SLA and SLO. They might sound similar, but they serve very different purposes.

Thursday, January 22, 2026

U.2 vs E3.S SSD: What Is the Difference?

When choosing enterprise NVMe storage for servers and data centers, two form factors are commonly discussed today: U.2 and E3.S. Although both are designed for high-performance and high-reliability workloads, they differ significantly in physical design, scalability, cooling, and long-term viability.

This article explains the key differences in a practical and easy-to-understand way.