TrendBreaker

TrendBreaker An Eurasian enterprise specializes in modern web and data science based solution for modern business needs. Just shoot a mail to [email protected]

TrendBreaker is comprised of a bunch of geeks who like to solve problems. We provide our customers with reliable custom software solutions. We are always happy to talk to you about your next big idea and how we can help you.

Postgres 19 is planning to change the default TOAST compression from pglz to LZ4, so let's look at how Postgres compress...
22/07/2026

Postgres 19 is planning to change the default TOAST compression from pglz to LZ4, so let's look at how Postgres compresses data in table storage and indexes. Postgres uses a single, unified compression framework for table (heap), TOAST, and indexes. In heap and TOAST, compression is automatic and on by default for variable-length types like TEXT, VARCHAR, BYTEA, and JSONB. In indexes, it is opportunistic: compression fires only when an individual key exceeds the size threshold, not for every variable-length value stored in an index.

History of Postgres Compression

Compression was first added in Postgres 7.0, released in 2000, but not in the form it takes today. At the time, Postgres had a strict 8kB maximum row size, and trying to insert more than 8kB would throw an error. Fixing this row size limit was a priority for the Postgres core team.

The first attempt to work around the limit was an explicitly compressed field. Postgres 7.0 shipped an lztext data type that used the pglz compression algorithm. This implementation had tradeoffs: the 8kB row limit still existed, and users had to explicitly choose a compressed data type.

After the 7.0 release, the next logical step might have been to add more compressed data types like LONG or BLOB (as many closed source databases were doing at the time). Instead, the Postgres core team rejected additional data types and rallied around TOAST. Discussions on the pgsql-hackers mailing list show the group split the 8kB problem into two distinct problems: a data type problem and a physical storage problem. Compression and TOAST were the answer to the physical storage problem.
TOAST with pglz

With Postgres 7.1, TOAST was implemented using pglz.

The pglz algorithm lives in the pg_lzcompress.c file. Because Postgres is open source, we can read the author's reasoning for home-rolling a compression algorithm right in the comments:

Trade ratio for speed: pglz is fast to compress and decompress, and willingly gives up compression ratio to get there. The source code calls this another "speed against ratio" preference characteristic of the algorithm.
Minimal memory usage: the algorithm uses a 4096-byte sliding window, small enough not to affect Postgres' memory needs. The comments note that the compressor works best for attributes of a size between 1K and 1M, so it trades away performance on very large values.
Aggressive fail-safe: the algorithm is designed to fail fast when data does not compress well, to avoid wasting CPU cycles.
No external dependencies: the algorithm is self-contained and does not require any external libraries. Back then, Linux was not the default server OS for the cloud (nor was there a "cloud"), so Postgres needed a compression algorithm that would work everywhere it was compiled.

Jan Wieck authored the algorithm and left an acknowledgement at the bottom of the file:

Many thanks to Adisak Pochanayon, who's article about SLZ inspired me to write the PostgreSQL compression this way.

Adisak Pochanayon's SLZ article described a compression scheme built for the game industry, where it was used to compress graphics and audio data.
Why move from pglz to LZ4?

pglz was built for a different era, and LZ4 is a modern algorithm whose tradeoffs match modern hardware. Postgres' LZ4 rollout follows a path similar to the original pglz implementation: first as an option, then as standard. Since Postgres 14, LZ4 has been available via a system-wide setting (default_toast_compression = 'lz4') or a column-specific setting (column_name text COMPRESSION lz4).

Faster compression: LZ4 compresses significantly faster than pglz. On an totally unscientific test, a 2,000 row INSERT of ~10 kB values, LZ4 completes in roughly 6 ms versus 50 ms for pglz (8× faster). Decompression throughput is similar between the two algorithms with this data set, as I/O and memory latency dominated over CPU decode time.
Better compression ratio (sometimes): LZ4's 64 kB sliding window (versus pglz's 4 kB) finds more back-references in the data, which expands compression. On a similar, totally unscientific workload, LZ4 produced 111 bytes stored per 10,400 bytes raw (98.9% reduction) versus pglz's 186 bytes (98.2% reduction), and used 312 kB of total heap space versus pglz's 472 kB. There are situations where pglz has a better compression ratio.
Continues to fail fast: LZ4 has an efficient early-abort mechanism designed to detect random or incompressible data quickly.

With Postgres 19 switching the default from pglz to LZ4, this post walks through the compression decision path, storage strategies, and index-size limits that shape real-world behavior.

24/06/2026

নিজের ল্যাপটপে কোড লিখে মডেল রান করে Jupyter Notebook এ সুন্দর সুন্দর গ্রাফ দেখা এক জিনিস, আর সেই Model কে লাইভ সার্ভারে ডেপ্লয় করে কোটি ইউজারের রিয়েলটাইম লোড হ্যান্ডেল করা সম্পূর্ণ অন্য জিনিস। এই আকাশ পাতাল গ্যাপটা বুঝতে না পারলে কোটি টাকার মেশিন লার্নিং কোর্স করেও দিনশেষে বেকার বসে থাকতে হবে।

​সফটওয়্যার ইঞ্জিনিয়ারিং আর ডাটা সায়েন্সের এই ডেডলি মিলনমেলা থেকেই জন্ম হয়েছে MLOps বা Machine Learning Operations এর। ​নতুনরা মনে করে একটা নরমাল সফটওয়্যার বা ওয়েবসাইটের মতো ML Model ও একবার সার্ভারে ছেড়ে দিলে বছরের পর বছর অটোমেটিক চলতে থাকবে। অথচ রিয়েল ইন্ডাস্ট্রির সবচেয়ে নির্মম সত্যি হলো, মডেল লাইভ করার পরদিনই তার পারফরম্যান্স ড্রপ করা শুরু করে। কারণ রিয়েল ওয়ার্ল্ডের Data প্রতিনিয়ত বদলাতে থাকে, মানুষের ট্রেন্ড আর চয়েস প্রতি মিনিটে চেঞ্জ হয়। আর ডাটার এই পরিবর্তনের সাথে সাথে মডেলের এক্যুরেসি যখন ডাস্টবিনে চলে যায়, তখন টেকনিক্যাল ভাষায় একে আমরা বলি Model Drift।

​ভাবুন একবার, ল্যাপটপে যে মডেল আপনাকে ৯৫ পার্সেন্ট এক্যুরেসি দিচ্ছিল, ইউজারের ডাটা বদলে যাওয়ার কারণে লাইভ সার্ভারে সেটা হুট করে ৫০ পার্সেন্টে নেমে আসলো। কোম্পানির তখন কোটি টাকার লস।

​এই কারণেই মডার্ন ইন্ডাস্ট্রিতে প্রোডাকশনে থাকা মডেলকে প্রতি সপ্তাহে বা প্রতি মিনিটে কন্টিনিউয়াসলি মনিটর করতে হয়। ডাটা পাইপলাইন ক্লিন রাখা, মডেল রিট্রেইন করা এবং অটোমেটেড ডেপ্লয়মেন্টের এই পুরো লাইফসাইকেল হ্যান্ডেল করার জন্য এখন Jenkins, Kubeflow, Prometheus আর MLflow এর মতো টুলস মডার্ন ইন্ডাস্ট্রিতে মাস্ট।

​সোজা বাংলায়, যারা শুধু মডেল বানাতে পারে কিন্তু MLOps বা ইনফ্রাস্ট্রাকচার বোঝে না, মডার্ন টেক জায়ান্টগুলোতে তাদের ডিমান্ড এখন একদম জিরো। পাইপলাইন ক্র্যাশ করার ভয় যার মাথায় নাই, সে আসলে এখনো রিয়েল ইঞ্জিনিয়ারই হয়ে উঠতে পারেনি।



Django is well known for being used to develop servers for HTTP connections and requests for applications. Unfortunately...
30/03/2026

Django is well known for being used to develop servers for HTTP connections and requests for applications. Unfortunately, when building Django chat app or any chat app that requires the connection to remain open for a two-way connection, using an HTTP connection is inefficient.

WebSockets provide a means of opening a two-way connection between the client and the server so that all users connected to the open network can get related data in real time. It is a stateful protocol, which means connection authentication is only required once; the client credential is stored, and there is no further need for authentication until the connection is lost.

In this article, I’ll briefly introduce you to WebSocket and its usefulness. Then, I’ll show you how to use it in Django using Django channels and create WebSocket connections with JavaScript to connect with the Django server.

We will build a simple chatbox to make things more realistic. You can find the code on GitHub.

Building stateful web applications can be tricky, unless you use a framework, of course. Django to the rescue! In this article, learn how to build a Djano chat...

Address

House 18, Road 5, PC Culture Housing
Dhaka
1207

Opening Hours

Monday 09:00 - 20:00
Tuesday 09:00 - 20:00
Wednesday 09:00 - 20:00
Thursday 09:00 - 20:00
Saturday 09:00 - 17:00
Sunday 09:00 - 20:00

Telephone

+8801913500913

Alerts

Be the first to know and let us send you an email when TrendBreaker posts news and promotions. Your email address will not be used for any other purpose, and you can unsubscribe at any time.

Contact The Business

Send a message to TrendBreaker:

Shortcuts

Share