merging multiple EXISTS(...) with constraint-based join removal #3998
-
Last brain dump of my day here. This optimization was never implemented in postgres -- would it make sense to do in postgREST? I expect you'll say "no" but given that it can sometimes be a huge optimization and postgREST's resource embeddings count() query is exactly the kind of EXIST generator described there, thought you all might be interested in considering |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The thread ends with a proposed algorithm for PostgreSQL to do that and with an invitation to work on it. I suppose any effort on this kind of optimization is better spent in the PostgreSQL source code :D. At lot more users would benefit from it. Additionally, step 3 seems to be much harder for us to do than for PostgreSQL. While we do have some metadata in the schema cache about uniqueness etc., upstream has all the information at hand for sure. |
Beta Was this translation helpful? Give feedback.
The thread ends with a proposed algorithm for PostgreSQL to do that and with an invitation to work on it. I suppose any effort on this kind of optimization is better spent in the PostgreSQL source code :D. At lot more users would benefit from it.
Additionally, step 3 seems to be much harder for us to do than for PostgreSQL. While we do have some metadata in the schema cache about uniqueness etc., upstream has all the information at hand for sure.