Consider the following situation: There is a complex (and time-consuming) query, which has some "slowly changing" parameters, i.e. the same query gets executed on the same data(-source) over and over again for a certain span of time. Then at some point both the source and the query get updated. Also assume that it is cheap (and fast) to determine whether the data(-source) has changed. Can I use the query plan together with a "hash of the source" as key for a lookup cache for pre-computed query results?

Would that be "safe" in principle, i.e. with the same plan and the same source data I can be sure to always get the "same" result. Could the "size" of the plan become too-large for use in a key to the cache?

I might be overlooking something obvious here, so happy to get feedback/suggestions about that idea in general also.