pgadmin-org / pgadmin-org/pgadmin4

Add option to display binary data (`BYTEA`) as hex-encoded strings

Open
#8,648 2 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature
Dominant language
Python
Stars
3.8k
Forks
891
Avg merge
4d 7h
Merged PRs (30d)
8

Description

Motivation

While the BYTEA-Datatype in Postgresql sounds like it should be used for BLOB storage, it can be useful in other contexts.

To give an example, an MD5 hash takes up about 22 Bytes of Storage when stored as NUMERIC, at 33 Bytes when stored as TEXT, but only 17 Bytes when stored as Bytea. In databases relying heavily on hashes and indexes on those hashes, using BYTEA therefore saves storage space and speeds up queries (There is some pressure from competitors here, in ORACLE databases, the NUMBER data type is as efficient as using BYTEA in Postgresql).

However, when developing a solution and trying to see at a glance if a query result is plausible, all those hash columns just display [binary data] if you forgot to add encode(..., 'hex') to them, resulting in a bad developer experience.

Solution I would like to see

To improve the developer experience when working with those bytea fields of quite limited length, it would be great if there was an option to display binary data as hex-encoded strings in the query output.

This could be a simple toggle in the Settings (File->Preferences->Query Tool->Results grid), and the resulting hex string could be treated like text and ellipsized if it reaches a certain length.

Alternatives I have considered

  • Migrating to storing hashes as strings purely to improve developer experience - resulting in a potentially significant storage and performance overhead
  • Maybe I could use a macro? I tried to add one to find out how they work and if they can accomplish this, but the "add Macro" button did nothing (Edit after reading the docs: I misunderstood what Macros do)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named in the issue. Start at File->Preferences->Query Tool->Results grid and trace how BYTEA values are rendered in query output. Done means an optional setting displays binary data as hex-encoded, ellipsized text without changing the default behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python
Domain
database, frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.