{
  "id": "enwiki-001291060957",
  "slug": "nested-loop-join",
  "title": "Nested loop join",
  "qid": "",
  "lead": "A nested loop join is a naive algorithm that joins two relations by using two nested loops. Join operations are important for database management.",
  "body": "A nested loop join is a naive algorithm that joins two relations by using two nested loops. Join operations are important for database management. ==Algorithm== Two relations R and S are joined as follows: algorithm nested_loop_join is for each tuple r in R do for each tuple s in S do if r and s satisfy the join condition then yield tuple This algorithm will involve n r *b s + b r block transfers and n r +b r seeks, where b r and b s are number of blocks in relations R and S respectively, and n r is the number of tuples in relation R. The algorithm runs in O(|R||S|) I/Os, where |R| and |S| is the number of tuples contained in R and S respectively and can easily be generalized to join any number of relations ... The block nested loop join algorithm is a generalization of the simple nested loops algorithm that takes advantage of additional memory to reduce the number of times that the S relation is scanned. It loads large chunks of relation R into main memory. For each chunk, it scans S and evaluates the join condition on all tuple pairs, currently in memory. This reduces the number of times S is scanned to once per chunk. ==Index join variation== If the inner relation has an index on the attributes used in the join, then the naive nest loop join can be replaced with an index join. algorithm index_join is for each tuple r in R do for each tuple s in S in the index lookup do yield tuple The time complexity for this variation improves from O(|R||S|) \\text{ to } O(|R|\\log|S|) ==See also== Hash join Sort-merge join ==References==",
  "categories": [
    "20346051",
    "22904253",
    "23118434",
    "23468805",
    "23603337",
    "24043274",
    "90877290"
  ],
  "license": "CC BY-SA 4.0",
  "source_uri": "https://en.wikipedia.org/w/index.php?oldid=1291060957",
  "content_hash": "",
  "created_at": null,
  "updated_at": 1747593731.0,
  "claims": [],
  "contradictions": [],
  "confidence": 0.6,
  "csl": {
    "id": "enwiki-001291060957",
    "type": "webpage",
    "title": "Nested loop join",
    "author": [
      {
        "family": "Anticloud FZ LLE",
        "literal": "Anticloud FZ LLE"
      }
    ],
    "container-title": "encyclopegia.org",
    "publisher": "Anticloud FZ LLE",
    "publisher-place": "Dubai, United Arab Emirates",
    "URL": "https://encyclopegia.org/a/nested-loop-join",
    "issued": {
      "date-parts": [
        [
          2026,
          11,
          18
        ]
      ]
    },
    "accessed": {
      "date-parts": [
        [
          2026,
          11,
          18
        ]
      ]
    },
    "license": "CC BY-SA 4.0",
    "DOI": "eo1:enwiki-001291060957",
    "isBasedOn": "https://en.wikipedia.org/w/index.php?oldid=1291060957",
    "note": "Immutable snapshot enwiki-001291060957"
  }
}