• Robert Haas's avatar
    postgres_fdw: Consider requesting sorted data so we can do a merge join. · ccd8f979
    Robert Haas authored
    When use_remote_estimate is enabled, consider adding ORDER BY to the
    query we sending to the remote server so that we can use that ordered
    data for a merge join.  Commit f18c944b
    arranges to push down the query pathkeys, which seems like the case
    mostly likely to be a win, but testing shows this can sometimes win,
    too.
    
    For a regular table, we know which indexes are present and therefore
    test whether the ordering provided by each such index is useful.  Here,
    we take the opposite approach: guess what orderings would be useful if
    they could be generated cheaply, and then ask the remote side what those
    will cost.
    
    Ashutosh Bapat, with very substantial cosmetic revisions by me.  Also
    reviewed by Rushabh Lathia.
    ccd8f979
postgres_fdw.sql 33.1 KB