# Leverage AccountsDB Infrastructure for Solana RPC Requests

> Leverage Alchemy’s AccountsDB Infrastructure for Solana RPC Requests!

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

The most expensive Solana RPC requests involve account scans, such as `getProgramAccounts` and `getLargestTokenAccounts`. These methods are incredibly useful but non-performant methods since they induce a heavy RPC load on Solana validator nodes, often resulting in a 5XX response due to timeout or a response with high latency.

Alchemy has built core infrastructure that sits atop our Solana validator nodes to support these methods at scale, through what we call the AccountsDB Infrastructure. This infrastructure provides **faster**, **scalable**, and more **reliable** responses to these methods by paginating the response with a `pageKey`. You can then loop through the same request with a scan and aggregate the full response from our validator nodes.

You can see `pageKey` is now an optional parameter in each account-scanning method in our Solana [docs](/docs/reference/getprogramaccounts), and you may also include an `order` optional parameter that would sort the accounts in the response by their `pubkey` field.

Here's an example with `getProgramAccounts`:

<CodeGroup>
  ```typescript typescript
  const axios = require("axios");

  async function getProgramAccountsExample() {
    let gPAExampleRequest = {
      method: "getProgramAccounts",
      params: [
        "ZETAxsqBRek56DhiGXrn75yj2NHU3aYUnxvHXpkf3aD",
        {
          encoding: "base64",
          withContext: true,
          order: "desc",
          dataSlice: {
            offset: 0,
            length: 10,
          },
        },
      ],
      id: 0,
      jsonrpc: "2.0",
    };
    let programAccounts = [];

    const alchemyRPCUrl =
      "https://solana-mainnet.g.alchemy.com/v2/<YOUR-API-KEY>";
    try {
      let response = await axios.post(alchemyRPCUrl, gPAExampleRequest);
      let responseData = response.data["result"];

      // continue aggregating if there's a new pageKey present in the latest response
      while (responseData["pageKey"]) {
        programAccounts = programAccounts.concat(responseData["value"]);

        // place the pagekey within the optional config object
        // (you may need to create that config object if you didn't have it originally)
        gPAExampleRequest["params"][1]["pageKey"] = responseData["pageKey"];

        // make another call to getProgramAccounts with the pageKey
        response = await axios.post(alchemyRPCUrl, gPAExampleRequest);
        responseData = response.data["result"];
      }

      programAccounts = programAccounts.concat(responseData["value"]);
      console.log(programAccounts);
      return programAccounts;
    } catch (err) {
      console.log(err.message);
      return [];
    }
  }
  ```
</CodeGroup>