Skip to content
Snippets Groups Projects
Select Git revision
  • benchmark-tools
  • postgres-lambda
  • master default
  • REL9_4_25
  • REL9_5_20
  • REL9_6_16
  • REL_10_11
  • REL_11_6
  • REL_12_1
  • REL_12_0
  • REL_12_RC1
  • REL_12_BETA4
  • REL9_4_24
  • REL9_5_19
  • REL9_6_15
  • REL_10_10
  • REL_11_5
  • REL_12_BETA3
  • REL9_4_23
  • REL9_5_18
  • REL9_6_14
  • REL_10_9
  • REL_11_4
23 results

nodeSort.c

Blame
    • Tom Lane's avatar
      d26559db
      Teach tuplesort.c about "top N" sorting, in which only the first N tuples · d26559db
      Tom Lane authored
      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
      History
      Teach tuplesort.c about "top N" sorting, in which only the first N tuples
      Tom Lane authored
      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.