Retrieving operations for a transaction unexpectedly slow?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite












I am trying to retrieve the operations for the transactions of a given ledger.



First retrieve the transactions:




 List<TransactionResponse> transactionResponses = this.server.horizonServer()
.transactions()
.forLedger(ledger)
.execute()
.getRecords();



Then retrieve the operations for each transactions:




 List<OperationResponse> operationResponses = this.server.horizonServer()
.operations()
.forTransaction(transactionHash)
.execute()
.getRecords();



The second call is one order of magnitude slower than the first one, for example:




[PERFORMANCE] getTransactions (10): 34 ms
[PERFORMANCE] getOperations (1): 274 ms
[PERFORMANCE] getOperations (1): 353 ms
[PERFORMANCE] getOperations (1): 294 ms
[PERFORMANCE] getOperations (1): 207 ms
[PERFORMANCE] getOperations (1): 307 ms
[PERFORMANCE] getOperations (1): 309 ms
[PERFORMANCE] getOperations (1): 301 ms
[PERFORMANCE] getOperations (1): 304 ms
[PERFORMANCE] getOperations (1): 293 ms
[PERFORMANCE] getOperations (1): 295 ms




Is there a better way of doings this? We are running our own Stellar node with the official Stellar docker image, so everything (database, stellar-code and horizon) is running locally.







share|improve this question







New contributor




Joanes Espanol is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • Do other horizon instances give similar results? (You can try the public horizon.stellar.org)
    – Tomer Weller
    Sep 8 at 0:03














up vote
4
down vote

favorite












I am trying to retrieve the operations for the transactions of a given ledger.



First retrieve the transactions:




 List<TransactionResponse> transactionResponses = this.server.horizonServer()
.transactions()
.forLedger(ledger)
.execute()
.getRecords();



Then retrieve the operations for each transactions:




 List<OperationResponse> operationResponses = this.server.horizonServer()
.operations()
.forTransaction(transactionHash)
.execute()
.getRecords();



The second call is one order of magnitude slower than the first one, for example:




[PERFORMANCE] getTransactions (10): 34 ms
[PERFORMANCE] getOperations (1): 274 ms
[PERFORMANCE] getOperations (1): 353 ms
[PERFORMANCE] getOperations (1): 294 ms
[PERFORMANCE] getOperations (1): 207 ms
[PERFORMANCE] getOperations (1): 307 ms
[PERFORMANCE] getOperations (1): 309 ms
[PERFORMANCE] getOperations (1): 301 ms
[PERFORMANCE] getOperations (1): 304 ms
[PERFORMANCE] getOperations (1): 293 ms
[PERFORMANCE] getOperations (1): 295 ms




Is there a better way of doings this? We are running our own Stellar node with the official Stellar docker image, so everything (database, stellar-code and horizon) is running locally.







share|improve this question







New contributor




Joanes Espanol is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • Do other horizon instances give similar results? (You can try the public horizon.stellar.org)
    – Tomer Weller
    Sep 8 at 0:03












up vote
4
down vote

favorite









up vote
4
down vote

favorite











I am trying to retrieve the operations for the transactions of a given ledger.



First retrieve the transactions:




 List<TransactionResponse> transactionResponses = this.server.horizonServer()
.transactions()
.forLedger(ledger)
.execute()
.getRecords();



Then retrieve the operations for each transactions:




 List<OperationResponse> operationResponses = this.server.horizonServer()
.operations()
.forTransaction(transactionHash)
.execute()
.getRecords();



The second call is one order of magnitude slower than the first one, for example:




[PERFORMANCE] getTransactions (10): 34 ms
[PERFORMANCE] getOperations (1): 274 ms
[PERFORMANCE] getOperations (1): 353 ms
[PERFORMANCE] getOperations (1): 294 ms
[PERFORMANCE] getOperations (1): 207 ms
[PERFORMANCE] getOperations (1): 307 ms
[PERFORMANCE] getOperations (1): 309 ms
[PERFORMANCE] getOperations (1): 301 ms
[PERFORMANCE] getOperations (1): 304 ms
[PERFORMANCE] getOperations (1): 293 ms
[PERFORMANCE] getOperations (1): 295 ms




Is there a better way of doings this? We are running our own Stellar node with the official Stellar docker image, so everything (database, stellar-code and horizon) is running locally.







share|improve this question







New contributor




Joanes Espanol is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










I am trying to retrieve the operations for the transactions of a given ledger.



First retrieve the transactions:




 List<TransactionResponse> transactionResponses = this.server.horizonServer()
.transactions()
.forLedger(ledger)
.execute()
.getRecords();



Then retrieve the operations for each transactions:




 List<OperationResponse> operationResponses = this.server.horizonServer()
.operations()
.forTransaction(transactionHash)
.execute()
.getRecords();



The second call is one order of magnitude slower than the first one, for example:




[PERFORMANCE] getTransactions (10): 34 ms
[PERFORMANCE] getOperations (1): 274 ms
[PERFORMANCE] getOperations (1): 353 ms
[PERFORMANCE] getOperations (1): 294 ms
[PERFORMANCE] getOperations (1): 207 ms
[PERFORMANCE] getOperations (1): 307 ms
[PERFORMANCE] getOperations (1): 309 ms
[PERFORMANCE] getOperations (1): 301 ms
[PERFORMANCE] getOperations (1): 304 ms
[PERFORMANCE] getOperations (1): 293 ms
[PERFORMANCE] getOperations (1): 295 ms




Is there a better way of doings this? We are running our own Stellar node with the official Stellar docker image, so everything (database, stellar-code and horizon) is running locally.









share|improve this question







New contributor




Joanes Espanol is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Joanes Espanol is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Sep 7 at 23:07









Joanes Espanol

211




211




New contributor




Joanes Espanol is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Joanes Espanol is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Joanes Espanol is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • Do other horizon instances give similar results? (You can try the public horizon.stellar.org)
    – Tomer Weller
    Sep 8 at 0:03
















  • Do other horizon instances give similar results? (You can try the public horizon.stellar.org)
    – Tomer Weller
    Sep 8 at 0:03















Do other horizon instances give similar results? (You can try the public horizon.stellar.org)
– Tomer Weller
Sep 8 at 0:03




Do other horizon instances give similar results? (You can try the public horizon.stellar.org)
– Tomer Weller
Sep 8 at 0:03










2 Answers
2






active

oldest

votes

















up vote
2
down vote













My best guess is that your PostgreSQL db works inefficiently with indexes on a large collection. Usually it means that your server has not enough RAM and is unable to keep indexes and cache in memory.



In order to find a bottleneck, you can analyze query performance with built-in PostgreSQL tools.






share|improve this answer



























    up vote
    1
    down vote













    If you need all operations per ledger you can use the Operations for Ledger endpoint. It won't necessarily be more performant per request but should reduce the number of requests you make.






    share|improve this answer








    New contributor




    Tomer Weller is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.

















    • Thanks for the tip, will check it out.
      – Joanes Espanol
      14 hours ago










    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "686"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    Joanes Espanol is a new contributor. Be nice, and check out our Code of Conduct.









     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstellar.stackexchange.com%2fquestions%2f1607%2fretrieving-operations-for-a-transaction-unexpectedly-slow%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    My best guess is that your PostgreSQL db works inefficiently with indexes on a large collection. Usually it means that your server has not enough RAM and is unable to keep indexes and cache in memory.



    In order to find a bottleneck, you can analyze query performance with built-in PostgreSQL tools.






    share|improve this answer
























      up vote
      2
      down vote













      My best guess is that your PostgreSQL db works inefficiently with indexes on a large collection. Usually it means that your server has not enough RAM and is unable to keep indexes and cache in memory.



      In order to find a bottleneck, you can analyze query performance with built-in PostgreSQL tools.






      share|improve this answer






















        up vote
        2
        down vote










        up vote
        2
        down vote









        My best guess is that your PostgreSQL db works inefficiently with indexes on a large collection. Usually it means that your server has not enough RAM and is unable to keep indexes and cache in memory.



        In order to find a bottleneck, you can analyze query performance with built-in PostgreSQL tools.






        share|improve this answer












        My best guess is that your PostgreSQL db works inefficiently with indexes on a large collection. Usually it means that your server has not enough RAM and is unable to keep indexes and cache in memory.



        In order to find a bottleneck, you can analyze query performance with built-in PostgreSQL tools.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Sep 7 at 23:44









        Orbit Lens

        4,3961723




        4,3961723




















            up vote
            1
            down vote













            If you need all operations per ledger you can use the Operations for Ledger endpoint. It won't necessarily be more performant per request but should reduce the number of requests you make.






            share|improve this answer








            New contributor




            Tomer Weller is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.

















            • Thanks for the tip, will check it out.
              – Joanes Espanol
              14 hours ago














            up vote
            1
            down vote













            If you need all operations per ledger you can use the Operations for Ledger endpoint. It won't necessarily be more performant per request but should reduce the number of requests you make.






            share|improve this answer








            New contributor




            Tomer Weller is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.

















            • Thanks for the tip, will check it out.
              – Joanes Espanol
              14 hours ago












            up vote
            1
            down vote










            up vote
            1
            down vote









            If you need all operations per ledger you can use the Operations for Ledger endpoint. It won't necessarily be more performant per request but should reduce the number of requests you make.






            share|improve this answer








            New contributor




            Tomer Weller is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.









            If you need all operations per ledger you can use the Operations for Ledger endpoint. It won't necessarily be more performant per request but should reduce the number of requests you make.







            share|improve this answer








            New contributor




            Tomer Weller is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.









            share|improve this answer



            share|improve this answer






            New contributor




            Tomer Weller is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.









            answered Sep 8 at 0:05









            Tomer Weller

            1113




            1113




            New contributor




            Tomer Weller is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.





            New contributor





            Tomer Weller is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.






            Tomer Weller is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.











            • Thanks for the tip, will check it out.
              – Joanes Espanol
              14 hours ago
















            • Thanks for the tip, will check it out.
              – Joanes Espanol
              14 hours ago















            Thanks for the tip, will check it out.
            – Joanes Espanol
            14 hours ago




            Thanks for the tip, will check it out.
            – Joanes Espanol
            14 hours ago










            Joanes Espanol is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            Joanes Espanol is a new contributor. Be nice, and check out our Code of Conduct.












            Joanes Espanol is a new contributor. Be nice, and check out our Code of Conduct.











            Joanes Espanol is a new contributor. Be nice, and check out our Code of Conduct.













             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstellar.stackexchange.com%2fquestions%2f1607%2fretrieving-operations-for-a-transaction-unexpectedly-slow%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            What does second last employer means? [closed]

            List of Gilmore Girls characters

            Confectionery