SShortSingh.
Back to feed

PostgreSQL NOT NULL column addition speed hinges on default value type.

0
·1 views

Adding a NOT NULL column to a large PostgreSQL table is fast if the default is a constant value, completing in milliseconds via a catalogue change. This performance stems from an optimization introduced in PostgreSQL 11. However, using a volatile default like gen_random_uuid() forces a full table rewrite, which is time-consuming and blocks other operations. To safely add a column requiring a per-row computed value, a three-step process of adding a nullable column, backfilling in batches, and then adding a constraint is recommended to avoid prolonged locks.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Analysis of 2026 app launch directories compares costs, queues, and requirements

A guide published on September 30 compares 21 platforms for launching new software applications. It details that most directories offer free listings, but these often require significant waiting periods, reciprocal links, or community votes. Paid options typically range from $10 to $40 for expedited listing, with a few services charging monthly subscription fees. The analysis advises developers to choose a platform based on their project's readiness, budget, and ability to meet specific community or technical requirements.

0
ProgrammingDEV Community ·

WordPress filter corrupts JavaScript regex by altering ampersand character

A developer discovered that a JavaScript tool embedded within a WordPress post functioned correctly locally but failed on the live site. The failure caused numeric digits to be replaced with the string 'undefined'. The issue was traced to WordPress's wptexturize filter converting a standalone ampersand (&) in a regex character class to its HTML entity (&). This altered the regex's matching behavior, causing it to incorrectly target digits 0, 3, and 8. The developer now recommends using Unicode escapes or external script files to avoid the filter.

0
ProgrammingDEV Community ·

Developer publishes customizable QR code API built with Rust

A developer has launched a customizable QR code generation API on RapidAPI. The project, built with Rust, allows extensive visual customization including gradients, shapes, and multiple output formats. It supports generating codes from various data types like URLs, Wi-Fi credentials, and contact information. The API also provides QR code decoding and validation functions. The developer created it to offer more flexibility than standard black-and-white QR generators.

0
ProgrammingDEV Community ·

Telegram Rejects iPhone Videos for Avatars; Bot Automates Conversion

Telegram's video avatar feature silently rejects videos recorded on iPhones. The issue stems from iPhones using the HEVC format by default, while Telegram only accepts H.264. A developer created a bot to automatically convert videos to meet Telegram's strict specifications. The required format is a square, 800x800 MP4 file under 2MB with no audio. The bot uses FFmpeg to crop, resize, and transcode videos into a compatible format.