QGIS map layer symbology can severely hinder the performance of queries to a postGIS server (due to inefficient text data type filtering)

Hello!
We experienced severe performance issues in a QGIS project which uses a postGIS server as a map layer back-end.
The issue is that the map symbology, and the selection of categories by users, can severely hinder the performance of queries to the server if there is no all other values category present / selected.

My question is whether it is generally agreeable that this should be considered a bug and reported with a minimal working example.
I do think so, but maybe this has been handled previously and I missed some project/layer property setting?
Although an affected project keeps working, it practically becomes unusable: background queries to the server in our case went up from the order of ~0.1s to more than 10s; given the frequency at which data is synced (on every scroll in QGIS or QField), this is a fatal show stopper.

Here a more detailed description:
We have map layers with “Categorized” symbology; the category is taken directly from the server to simplify debugging (status is a varchar field in a view which also contains one point geometry field).

The issue is the last category: the overflow category all other values.
When it is missing from (i) this category list or (ii) the users’ selection of symbols to display, then the otherwise efficient query will become slow as a snail, even if there is no single uncategorized feature remaining.

This has caused some paradox behavior: if I forgot to add “all other values” to our projects, the whole projects would become unusable although the query that is behind the view and map layer is quasi-instantaneous (<10000 rows x 30 fields, peanuts really). If people filter the actually unused category from their map layer symbols in QGIS or QField, their performance degrades spot-on, but this happens by user input and is a headache for the database admin who cannot see any obvious issues on the back-end.

After a long day of irrelevant query profiling and pseudo-optimization, I could trace this in the “Debugging/Development Tools >> query logger”.

The query does change drastically by removing the “all other values” from the set:

Namely the last line, a WHERE filter for status, is added.
This is a really inefficient addition: firstly because status is explicitly cast to text (data type not suitable for filtering comparisons), and secondly because this implicit status filter causes significant server load. Symptom: whenever we “moved the map” on any QField client, this hidden filter drained a full CPU for the duration of 10s on the humble host machine (HHM).

Now, the reason I recently moved the status to the server is readability and debugging: I used to have issues with maintaining the complex categorization (and labeling) expressions in QGIS when my data model changed; also, data accidentally ending up in the missing “all other values” has caused trouble before by becoming rather invisible without me noticing. Thus, I think it is a valid strategy to use text expressions pre-compiled on the postgres side.

I do not know whether the query building in QGIS should be changed for this (my tendency is to think: yes this must be implemented in a more efficient way; but I might be biased). What I would expect is maybe an option to choose, in the symbology tab of layer properties to (A) always load all features in the region of interest and then filter symbol categories on the QGIS side, or (B) filter server side via query as it happens now. This choice could be coupled with a warning.

Thank you for advice on how to proceed with this!