(apropos: now there's an AI feature I can get behind. Automatic summarization of links, so we can filter the clickbait).
But I do know that whatever the question, Postgres is the answer.
what IS the answer for everything, by the way?
"During a query that references any remote tables on a foreign server, postgres_fdw opens a transaction on the remote server if one is not already open corresponding to the current local transaction. The remote transaction is committed or aborted when the local transaction commits or aborts. Savepoints are similarly managed by creating corresponding remote savepoints."
My firm looked into Postgres extremely deeply aka source code around text search and AI. I would highly recommend against using this, and stick to more standard ways of doing NLP. Postgres still has open bugs around text search and lifting limits from 5 years ago. We concluded we couldn't trust anything but the core ecosystem around it.
And as the article notes "Postgres is equipped" to query, format and return the data needed.
[1]: https://aihelperbot.com/videos/preview-use-ai-to-become-your...
ie.: I asked it to write a query to check how many times "user A" triggered "event X" before triggering "event Y" (with a column of their timestamps).
Never returned the right answer.
Beyond the prompt as you see above, I added the events table with id, userName, eventType and date field. Adding your database tables gives (in my experience) high accuracy.