Reducing latency in read operationsCorrect way to write this query?Get categorie, subcategories and number of...

How do I avoid the "chosen hero" feeling?

Why don't programs completely uninstall (remove all their files) when I remove them?

How can I handle players killing my NPC outside of combat?

Why is it that Bernie Sanders always called a "socialist"?

Why write a book when there's a movie in my head?

Two oatmeal pies a day keep the doctor away?

Reason for small-valued feedback resistors in low noise Op Amp

Is the percentage symbol a constant?

Crack the bank account's password!

Why don't you get burned by the wood benches in a sauna?

Is there any way to play D&D without a DM?

Is the UK legally prevented from having another referendum on Brexit?

Plotting Laguerre Gaussian beam intensity in transverse and line profile via center?

What does "move past people" mean in this context?

Can a planet be tidally unlocked?

Why is Shelob considered evil?

Coworker is trying to get me to sign his petition to run for office. How to decline politely?

Why would you use 2 alternate layout buttons instead of 1, when only one can be selected at once

Have any astronauts or cosmonauts died in space?

Create a line break in a subscript-position term

What is an efficient way to digitize a family photo collection?

Expression for "unconsciously using words (or accents) used by a person you often talk with or listen to"?

What is an explicit bijection in combinatorics?

Tikz: Perpendicular FROM a line



Reducing latency in read operations


Correct way to write this query?Get categorie, subcategories and number of products assigned to eachA table that consists of multiple FK or creating separate tables for each FKHow to speed up ORDER BY sorting when using GIN index in PostgreSQL?Optimization of complicated sums and counts in related tablesFilter by list of values pairsHow to model an entity type that can have different sets of attributes?MariaDB choosing the wrong index for large tablesRandomly select 4 items of a randomly selected categoryWhat slows down this histogram query?













0















Table size 45 million rows
Schema: item name, categories and subcategories, order quantity and price.



What is the fastest way to put each item into an appropriate bucket.



Eg, price range given will be: 500- 600
And we have 10 buckets: 500-510, 510-520, ...590-600
We also have filters on particular category and subcategory, i.e. specific category and subcategory have to be only considered in a query.



By bucketing it means that all items which falls in a said range, and belongs to the particular category and subcategory, there order quantity will be summed.



What will be an optimal way to construct the query. We have a query which does all the processing in one go using case and when. However, this takes around 18 sec or more mostly.
This has to be optimized. I have tried adding indexes, which is not helping much.









share







New contributor




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

























    0















    Table size 45 million rows
    Schema: item name, categories and subcategories, order quantity and price.



    What is the fastest way to put each item into an appropriate bucket.



    Eg, price range given will be: 500- 600
    And we have 10 buckets: 500-510, 510-520, ...590-600
    We also have filters on particular category and subcategory, i.e. specific category and subcategory have to be only considered in a query.



    By bucketing it means that all items which falls in a said range, and belongs to the particular category and subcategory, there order quantity will be summed.



    What will be an optimal way to construct the query. We have a query which does all the processing in one go using case and when. However, this takes around 18 sec or more mostly.
    This has to be optimized. I have tried adding indexes, which is not helping much.









    share







    New contributor




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























      0












      0








      0








      Table size 45 million rows
      Schema: item name, categories and subcategories, order quantity and price.



      What is the fastest way to put each item into an appropriate bucket.



      Eg, price range given will be: 500- 600
      And we have 10 buckets: 500-510, 510-520, ...590-600
      We also have filters on particular category and subcategory, i.e. specific category and subcategory have to be only considered in a query.



      By bucketing it means that all items which falls in a said range, and belongs to the particular category and subcategory, there order quantity will be summed.



      What will be an optimal way to construct the query. We have a query which does all the processing in one go using case and when. However, this takes around 18 sec or more mostly.
      This has to be optimized. I have tried adding indexes, which is not helping much.









      share







      New contributor




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












      Table size 45 million rows
      Schema: item name, categories and subcategories, order quantity and price.



      What is the fastest way to put each item into an appropriate bucket.



      Eg, price range given will be: 500- 600
      And we have 10 buckets: 500-510, 510-520, ...590-600
      We also have filters on particular category and subcategory, i.e. specific category and subcategory have to be only considered in a query.



      By bucketing it means that all items which falls in a said range, and belongs to the particular category and subcategory, there order quantity will be summed.



      What will be an optimal way to construct the query. We have a query which does all the processing in one go using case and when. However, this takes around 18 sec or more mostly.
      This has to be optimized. I have tried adding indexes, which is not helping much.







      mysql index query-performance optimization aws-aurora





      share







      New contributor




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










      share







      New contributor




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








      share



      share






      New contributor




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









      asked 6 mins ago









      AnonymousAnonymous

      1




      1




      New contributor




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





      New contributor





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






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






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "182"
          };
          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Anonymous 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%2fdba.stackexchange.com%2fquestions%2f230543%2freducing-latency-in-read-operations%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








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










          draft saved

          draft discarded


















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













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












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
















          Thanks for contributing an answer to Database Administrators Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f230543%2freducing-latency-in-read-operations%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Szabolcs (Ungheria) Altri progetti | Menu di navigazione48°10′14.56″N 21°29′33.14″E /...

          Discografia di Klaus Schulze Indice Album in studio | Album dal vivo | Singoli | Antologie | Colonne...

          How to make inet_server_addr() return localhost in spite of ::1/128RETURN NEXT in Postgres FunctionConnect to...