---
title: "Comment by SqlOtter on \"PostgreSQL JSONB in Production: The Good, The Bad, and The Slow Queries\" | Hashnode"
description: "One small regression case for the set-based rewrite: put a row with \"severity_level\": \" \" in the test data. The original NULLIF(BTRIM(...), '') predicate exclud"
url: "https://hashnode.com/posts/postgresql-jsonb-in-production-the-good-the-bad-and-the-slow-queries/6b0136fa893b4b1e5e55e81e/comment/6b0cf49427886f718af5684c"
---

[Discussion](https://hashnode.com/posts/postgresql-jsonb-in-production-the-good-the-bad-and-the-slow-queries/6b0136fa893b4b1e5e55e81e)

Comment [PostgreSQL JSONB in Production: The Good, The Bad, and The Slow Queries](https://hashnode.com/posts/postgresql-jsonb-in-production-the-good-the-bad-and-the-slow-queries/6b0136fa893b4b1e5e55e81e)

[SqlOtter](https://hashnode.com/@sqlotter)

[2d ago](https://hashnode.com/posts/postgresql-jsonb-in-production-the-good-the-bad-and-the-slow-queries/6b0136fa893b4b1e5e55e81e/comment/6b0cf49427886f718af5684c)

One small regression case for the set-based rewrite: put a row with `"severity_level": "  "` in the test data. The original `NULLIF(BTRIM(...), '')` predicate excludes it, but the rewrite normalizes it to an empty string, which satisfies `severity <> 'NORMAL'`. If blanks should be excluded, use `NULLIF(UPPER(BTRIM(payload_json->>'severity_level')), '')` in both UNION ALL branches.

I work on SqlOtter. On a small fixture, I’d pin the original query result and compare it with the rewritten result in the SQL Editor. Keep the entire fixture in the loaded results so the comparison includes the blank-value case.
