• T
    Teach tuplesort.c about "top N" sorting, in which only the first N tuples · d26559db
    Tom Lane 提交于
    need be returned.  We keep a heap of the current best N tuples and sift-up
    new tuples into it as we scan the input.  For M input tuples this means
    only about M*log(N) comparisons instead of M*log(M), not to mention a lot
    less workspace when N is small --- avoiding spill-to-disk for large M
    is actually the most attractive thing about it.  Patch includes planner
    and executor support for invoking this facility in ORDER BY ... LIMIT
    queries.  Greg Stark, with some editorialization by moi.
    d26559db
planner.c 54.5 KB