# How improve performance in the calculation of a portfolio data

**URL:** <https://community.bitquery.io/t/how-improve-performance-in-the-calculation-of-a-portfolio-data/2113>\
**Category:** GraphQL API\
**Tags:** support\
**Created:** [October 11, 2024, 9:41am UTC](https://community.bitquery.io/t/how-improve-performance-in-the-calculation-of-a-portfolio-data/2113 "2024-10-11T09:41:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jramirez](https://sea2.discourse-cdn.com/flex016/user_avatar/community.bitquery.io/jramirez/32/957_2.png) [@jramirez](https://community.bitquery.io/u/jramirez)\
**Post date:** [October 11, 2024, 9:41am UTC](https://community.bitquery.io/t/how-improve-performance-in-the-calculation-of-a-portfolio-data/2113/1 "2024-10-11T09:41:10Z")

</div>

Hi guys,

I am currently calculating the portfolio of an address this way:

First I get all the tokens with [balance](https://ide.bitquery.io/getTokenBalances_1) from a particular wallet.

Once I have the list of token addresses, I get all the [trades](https://ide.bitquery.io/getTokenTrades_5) in the last 6 month for those tokens. This queries take usually more than **15 seconds** for just one wallet and array of tokens. I need some help to improve the performance of that.

Finally I get init token balance, current price and price in the last 24 hours.

What can I do to improve or even aggregate these queries in one or two, in order to get a better performance?

Thank you,

---

<div class="post-metadata">

**Author:** ![Divya](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@Divya](https://community.bitquery.io/u/Divya)\
**Post date:** [October 11, 2024, 9:46am UTC](https://community.bitquery.io/t/how-improve-performance-in-the-calculation-of-a-portfolio-data/2113/2 "2024-10-11T09:46:55Z")

</div>

Okay, if you are querying data which is not realtime, use ` "dataset": "archive"` , it speeds up the query. `combined` is costlier and takes time since it queries both realtime & archive

Let me check and come back on other optimizations.

---

<div class="post-metadata">

**Author:** ![jramirez](https://sea2.discourse-cdn.com/flex016/user_avatar/community.bitquery.io/jramirez/32/957_2.png) [@jramirez](https://community.bitquery.io/u/jramirez)\
**Post date:** [October 11, 2024, 9:52am UTC](https://community.bitquery.io/t/how-improve-performance-in-the-calculation-of-a-portfolio-data/2113/3 "2024-10-11T09:52:43Z")

</div>

I tried with archive and took more time, 39 seconds D:

 ![image](https://us1.discourse-cdn.com/flex016/uploads/bitquery/original/1X/5c023296722d6cd5557721be460a27c04c1a7081.png)

---

<div class="post-metadata">

**Author:** ![Divya](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@Divya](https://community.bitquery.io/u/Divya)\
**Post date:** [October 11, 2024, 9:58am UTC](https://community.bitquery.io/t/how-improve-performance-in-the-calculation-of-a-portfolio-data/2113/4 "2024-10-11T09:58:45Z")

</div>

took 25 secs for me. `archive` is faster than `combined` in general.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/bitquery/original/1X/cf138f9faa80e255c551088d0757025599a1080f.jpeg)
