> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinetica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SqlIterator

### SqlIterator

<ul>
  <li>
    SqlIterator(\
    &#x20;sql: string,\
    &#x20;batchSize?: number,\
    &#x20;sqlOptions?: Record\<string, string>,\
    ): AsyncGenerator\<Record\<string, any>, void, undefined>

    Iterates the results of an SQL statement, fetching in batches.Pages through the result set so arbitrarily large queries can be consumed without holding everything in memory at once, cleaning up any server-side paging tables when iteration finishes -- including when the caller breaks out of the loop early.Records are yielded as objects keyed by column name. This differs from the JavaScript API, which yields positional arrays; use `Object.values(record)` if you need those.

    #### Parameters

    <ul>
      <li>
        sql: string

        The SQL statement to execute
      </li>

      <li>
        batchSize: number = 10000

        Records to fetch per batch; defaults to 10000
      </li>

      <li>
        sqlOptions: Record\<string, string> = \{}

        Options passed through to `/execute/sql`
      </li>
    </ul>

    #### Returns AsyncGenerator\<Record\<string, any>, void, undefined>

    #### Example

    ```
    for await (const row of gpudb.SqlIterator('SELECT * FROM big_table')) {
        console.log(row.id, row.name);
    }
    ```

    <ul>
      <li>Defined in [src/GPUdb.ts:16359](https://github.com/kineticadb/kinetica-api-typescript/blob/master/src/GPUdb.ts#L16359)</li>
    </ul>
  </li>
</ul>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.