SQL (PostgreSQL) optimization question

Hi friends! I'm struggling with a query optimization problem, where the
logical solution is clear but I'm not sure SQL supports any mechanism to implement it.

The problem is that I have large number of similar queries, each fetching the same type of data, performing similar baseline filtering, and following up with case-specific selection logic. For
all of these queries, 99% of execution time is spent in the "similar baseline filtering" step, particularly in an ugly (but necessary) recursive join with up to 4 recursions for each row.

This is where the optimization is possible: the values retrieved by those recursions will
almost never change once they've been calculated. With a small change to application logic, they can be made to actually never change - the value will be deterministic from the moment each row is inserted.

Unfortunately,
I cannot change the schema of this table. If I could, then I'd just add a block of de-normalized fields and call it a day. And if the queries weren't paginated, then I could move the filtering into application code and cache it there. But neither option is possible here, so I'm faced with the prospect of teaching PostgreSQL how to cache the result of a join.

I first considered Materialized Views, which seemed like a perfect solution until I realized that they don't automatically add new rows. I'd have to refresh the whole thing a hundred times per second which is obviously not practical.
Regular Views are also not an option, as we'd still execute the recursive join on every query. I could potentially add a new table containing just the resolved values, populated from a trigger on the source table - but our migration tooling doesn't support triggers, so I'd have to implement that first. It will also still require a join (just not a recursive one).

Currently, I'm leaning towards option 3 - new table with trigger. But given the downsides, I'd like to make sure I didn't miss any better solution.
Does anyone have thoughts, suggestions, or ideas for this? Any help will be greatly appreciated!!

#SoftwareDevelopment #SoftwareDev #DevHelp #SQL #PostgreSQL
Daz - [Help] Is My PC Good Enough for a DAZ3D + Ren'Py Game Project?

Hi everyone, I’m planning to start developing a visual novel style game using DAZ3D for rendering and Ren’Py as the engine. Before I fully commit, I wanted to ask for advice about whether my current system is sufficient for this type of workflow. My setup: GPU: RTX 5070 (12 GB VRAM) CPU...

F95zone | Adult Games | Comics | Mods | Cheats
Daz - [Help] Is My PC Good Enough for a DAZ3D + Ren'Py Game Project?

Herkese merhaba, DAZ3D ile renderlama ve Ren'Py ile oyun motoru kullanarak görsel roman tarzında bir oyun geliştirmeyi planlıyorum. Tamamen başlamadan önce, mevcut sistemimin bu tür bir iş akışı için yeterli olup olmadığı konusunda tavsiye almak istedim. Benim kurulumum: GPU: RTX 5070 (12 GB...

F95zone | Adult Games | Comics | Mods | Cheats
AI game monetisation

Hello everyone, I always wanted to make an adult game and I’ve recently started that project with the help of AI for creating photorealistic characters. The main issue I’m facing is monetisation. Right now I’ve barely had traction on the game but thinking longer term, Patreon specifically...

F95zone | Adult Games | Comics | Mods | Cheats
Daz - Genital distortion issue when posing legs up (Golden Palace Genesis 9) [SOLVED]

Hi, I recently downloaded the Golden Palace content (Genesis 9). Everything was working fine at first, but after a while I ran into an issue that I can’t ignore and that’s quite frustrating. When I apply poses where the legs are raised upward, there’s noticeable distortion in the character’s...

F95zone | Adult Games | Comics | Mods | Cheats
Ren'Py - adding icon to dialogue

whats wrong with this????

F95zone | Adult Games | Comics | Mods | Cheats
Making h scenes

I need your help, guys. I'm about to lose my mind here. First of all, I'm not a game developer, but since I had a similar issue, I thought I could seek help here. My goal is to use Koikatsu to create sex scenes with my favorite anime characters—completely for my personal, perverted purposes...

F95zone | Adult Games | Comics | Mods | Cheats
Issue accessing game sections / Account verification status

I recently registered an account on F95zone and verified my email. However, I am unable to see the 'Games' or 'WIP' sections of the forum. I am trying to post a new game development project, but I don't see the option to create a thread or view the game subforums. Could you please check if my...

F95zone | Adult Games | Comics | Mods | Cheats
General development advice?

Hey all, I was just wondering if any solo developers have some general advice on creating a game. Ive been learning Daz3d, Renpy and stable diffusion and im about ready to put it all together. However im little unsure the most time effective way to build it. I have a story mapped out with a...

F95zone | Adult Games | Comics | Mods | Cheats
Daz - what's wrong with this render?

how can i improve the lightning here? it feels off to me?

F95zone | Adult Games | Comics | Mods | Cheats