Re: AW: Optimizer Hint, to ignore limit and offset in optimizer plan
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Martin Handsteiner <martin.handsteiner@sibvisions.com>
Cc: Simon Riggs <simon@2ndquadrant.com>,
"pgsql-sql@lists.postgresql.org" <pgsql-sql@lists.postgresql.org>
Date: 2020-06-29T14:30:19Z
Lists: pgsql-sql
Martin Handsteiner <martin.handsteiner@sibvisions.com> writes: > yes, this would exactly be the feature I was talking about. > enable_costlimit = true (default) | false > How high is the possibility, that this feature will find the way into the postgres db? Not very good, unless you can present a far more convincing use-case. If I understand your desire, it is that issuing the "same" query in different transactions would generate identical overall results despite varying the offset/limit so as to fetch different parts of that unchanging result. The problem with this is that whether changing the offset/limit changes the plan shape is just one of many reasons why you might not get a consistent result --- the most unavoidable being that other transactions might commit data changes. Moreover, you insist that you shouldn't have to use an ORDER BY to get these consistent results. Sorry, but SQL is *defined* to not produce consistent row ordering without ORDER BY. Changing that isn't a matter of some optimizer hint somewhere, it's a very fundamental thing in many places. I'd counsel taking another look at the suggestion made upthread to use a cursor WITH HOLD. regards, tom lane