Algorithm Search⌘K

Query processing

Problems

  • Group-by aggregation problem

    Split the rows of a relation into groups by a key and compute an aggregate such as COUNT, SUM or AVG over each group.

    1 languagesintro
  • Relational join problem

    Given relations R and S and a join condition, output every pair of tuples, one from each relation, that satisfies the condition, combined into one tuple.

    intro
  • Acyclic join evaluation problem

    Evaluate a join whose hypergraph is alpha-acyclic, that is, has a join tree. It is solvable in time linear in input plus output for full joins.

    1 languagesadvanced
  • Multiway join problem

    Given three or more relations, compute their natural join. Plans of two-way joins can build intermediate results far larger than the output; multiway algorithms avoid this.

    advanced
  • Top-k query problem

    Given m lists that grade the same objects, each sorted by its grade, find the k objects with the highest combined score while reading as little of the lists as possible.

    advanced

Algorithms

  • Block nested-loop join

    A nested-loop join that reads the outer relation in blocks of B - 2 pages and scans the inner relation once per block, often with a hash table on the block.

    Θ(p q M N) worst1 languagesintro
  • Hash aggregation

    Group and aggregate rows in a hash table keyed by the group, with one partial state per group; spill new groups to hash partitions when memory is full.

    O(n (1 + d/m)) worst1 languagesintro
  • Hash join

    Build a hash table on the join key of the smaller relation, then scan the larger relation and probe the table with each tuple. One pass, M + N page reads, if the table fits in memory.

    Θ(p q M N) worst1 languagesintro
  • Index nested-loop join

    A nested-loop join that, for each tuple of the outer relation, probes an index on the join attribute of the inner relation instead of scanning it.

    O(p M C + T) worst · average · best1 languagesintro
  • Nested-loop join

    Join two relations by testing every pair of tuples: for each tuple or page of the outer relation, scan the whole inner relation. Works for any join condition.

    Θ(p q M N) worst · average · best1 languagesintro
  • Sort-merge join

    Sort both relations on the join attribute with external merge sort, then scan them in step and pair the groups of equal keys. About 3(M + N) page I/Os with enough memory.

    Θ(p q M N) worst1 languagesintro
  • Grace hash join

    Split both relations into B - 1 partitions on disk with one hash function, then join each pair of partitions with an in-memory hash table and a second hash function. 3(M + N) I/Os.

    Θ(p q M N) worst1 languagescore
  • Sort-based aggregation

    Sort the rows on the grouping key with an external merge sort, and combine rows of equal key into one partial state while the runs are formed and merged.

    O(n log n) worst · best1 languagescore
  • Block-nested-loop skyline

    Skyline by scanning: keep a window of incomparable tuples in memory, spill the overflow to a temporary file, and use timestamps to output tuples once they have met all others.

    O(d n^2) worst1 languagesadvanced
  • Bloom join

    Send a Bloom filter of the join keys of S to the site of R, keep only the tuples of R that pass it, and join them with S. False positives cost data but never lose a match.

    Θ(k (p M + q N) + p q M N) worst1 languagesadvanced
  • Bottom-up cube computation (BUC)

    Compute an iceberg cube from the group-by ALL toward more specific group-bys, and skip each partition whose row count is below the threshold.

    O(2^D n (log n + q)) worst1 languagesadvanced
  • Branch-and-bound skyline

    Find the skyline with an R-tree: take entries from a heap in order of L1 mindist from the origin, and drop each entry whose lower corner a skyline point found so far dominates.

    O(r b (log(r b) + s d)) worst1 languagesadvanced
  • Fagin's algorithm

    Top-k over m graded lists: read all lists in parallel until k objects have been seen in every list, then fetch missing grades by random access.

    O(m^2 n) worst1 languagesadvanced
  • Holistic twig join

    Match a tree pattern of an XML query over sorted element streams with one stack per query node. With only ancestor-descendant edges, no intermediate result is wasted.

    O(k (n + l z)) worst1 languagesadvanced
  • Hybrid hash join

    Keeps the first partition of the smaller relation in memory as a hash table while it partitions the rest, so that part of both inputs is joined at once and never written to disk.

    Θ(p q M N) worst1 languagesadvanced
  • No-random-access algorithm

    Top-k over m graded lists with sorted access only: keep a lower and an upper bound on each seen score, and stop when no other object can beat the k best lower bounds.

    O(m n) worst1 languagesadvanced
  • Radix hash join

    Cluster both inputs on the low bits of a hash, in passes with a small fan-out, so that each cluster fits in the cache. Then join each pair of clusters with a small hash table.

    O(P(n + m) + 2^b + n m) worst1 languagesadvanced
  • Rank join

    Join two inputs sorted by score and output the results in order of a monotone combined score. Stop when a threshold shows that no pair not yet formed can enter the top k.

    O(n + m + n m log(n + m)) worst1 languagesadvanced
  • Ripple join

    A join for online aggregation. It reads both inputs in random order, joins each new tuple with all tuples read from the other input, and scales the running sum into an unbiased estimate.

    O(n m) worst1 languagesadvanced
  • Sort-filter-skyline

    Skyline by presorting on a monotone score such as entropy, then one window filter: a tuple that no window tuple dominates is in the skyline and is output at once.

    O(n log n + d n^2) worst1 languagesadvanced
  • Threshold algorithm

    Top-k over m graded lists: score each object on first sight by random access, and stop once k objects score at least t applied to the last grades read.

    O(m^2 n) worst1 languagesadvanced
  • Yannakakis algorithm

    Evaluate an acyclic join on its join tree: semijoin passes up and down remove every dangling tuple, then joins in time linear in input plus output.

    O(r n + r z) expected1 languagesadvanced
  • Generic join

    Join many relations one attribute at a time: intersect the candidate values from each relation, loop over the smallest set; the time is within the AGM bound.

    O(k n log n + k r a log n) worst1 languagesresearch
  • Leapfrog triejoin

    A worst-case optimal multiway join: bind one attribute at a time, and intersect sorted trie levels by seeks that jump each list to the largest current key.

    O(k n log n + k r a log n) worst1 languagesresearch

Data structures

  • Factorized representation

    A join result stored as nested unions and products over a tree of attributes. It can be much smaller than the list of its tuples, and the tuples can still be listed one by one.

    O(k r (k + n) n^s) worst1 languagesresearch

Techniques

  • Iterator model (Volcano)

    Run a query plan by giving each operator open, next and close. The root pulls tuples one at a time, so most operators pipeline and need no stored result.

    1 languagesintro
  • Exchange operator

    An operator that splits a plan into parallel streams by partitioning, broadcasting or merging tuples, so other operators stay serial.

    core
  • Data-centric query compilation

    Compile each pipeline of a plan into one tight loop that pushes tuples through its operators, keeping values in registers.

    advanced
  • Online aggregation

    Read the input of an aggregate query in random order and keep a running estimate of each answer with a confidence interval, so that the user can stop as soon as the answer is good enough.

    1 languagesadvanced
  • Vectorized query execution

    Operators exchange batches of column values instead of single tuples, which amortizes call overhead and lets tight loops use SIMD.

    advanced
  • Morsel-driven parallelism

    Split the input of each pipeline into small morsels that worker threads take dynamically, which balances load on many cores.

    research

Concepts

  • Semijoin

    The tuples of R that have at least one matching tuple in S, written R ⋉ S. Semijoins shrink relations before a join and fully reduce the relations of a tree query.

    intro
  • Pipelining and materialization

    Operators either pass tuples to the next operator as they are produced or write a full intermediate result; blocking operators break pipelines.

    core

Definitions

  • Data cube

    The aggregates of a fact table over all subsets of a set of grouping attributes, as defined by the CUBE operator of Gray et al.

    core

Theorems

  • AGM bound

    A join's output size is at most the product of |R_e|^(x_e) for any fractional edge cover x of its hypergraph; the best cover gives a bound that some instances reach.

    1 languagesadvanced