Timeout of query in hammer and web-ui

Hello!
we have an serious performance problem with som queries. All
following queries executed with foreman admin account

hostgroup_title ~ foo and facts.os::name = Debian and facts.faa="fxxx"
this runs 5sec and returns the correct result

and the query
hostgroup_title ~ foo and facts.os::name = Debian and facts.faa="fyyy"
runs also 5sec returns the correct result

but
hostgroup_title ~ foo and facts.os::name = Debian and (facts.faa=“fyyy” or facts.faa=“fxxx”)
runs forever in foreman web-ui. in hammer after a long time (~8min) I only get a small part of the result (I suspect a timeout)

The combined result of query 1 and 2 in a “normal” time.

We use Foreman Version 1.21.4 with postgresql as DB. We have

We are managing ~5500 puppet nodes in forman

This looks like Bug #21625: Host search using OR on facts finds duplicate records and takes a long time - Foreman that may have already been resolved in 1.23 due to the fix for Bug #25897: Using search query for listing content hosts produces unexpected output - Foreman