Greg Stark <[EMAIL PROTECTED]> writes: > At what point in the process would it make sense to check for this?
You'd need to mess with the code that generates "pathkeys" describing the sort ordering of index scans --- read about pathkeys in src/backend/optimizer/README. As Hannu notes nearby, the existing code is not broken for cases like explain select * from test where a=1 order by a,b; and it would not be cool to break that case while fixing explain select * from test where a=1 order by b; This probably means that you'd need to offer up multiple pathkey descriptions of an index's sort order, ie, both ((a), (b)) and ((b)). I'm not sure how painful that would be. You could quick-hack it by generating multiple indexscan Paths that are really identical but have different pathkeys --- but I think that would have unpleasant consequences for planning time ... it'd be better to attach multiple pathkeys to a single Path. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend