Giter Site home page Giter Site logo

Comments (1)

ilmartyrk avatar ilmartyrk commented on July 1, 2024

Read a lot of Postgres documentation about functions, indexing:

also looked around for articles. Probably the simplest to understand and try out was this:

  • https://statsbot.co/blog/postgresql-query-optimization/
    Took apart all the main queries and run them separately to find the slowest and found out that they were quite ok. So after that rewrote query that built the returning data into a function and that helped to bring down the cost, but performance got really slow. Finally concentrated on query order. So to first narrow down ID-s to return and after that get all data that is only related to these.
    To get better picture from queries used:
  • http://tatiyants.com/pev/#/plans
    Final results without adding any new indexes or altering DB structure (Run on local DB with about 30000 rows in Activities table, created by re-running all the tests over and over):
    Query cost from: 30821841.70 -> 207202.78
    Execution time 2247.545 -> 607.797 ms
    Memory usage under load test described in this issue ~180MB -> ~40MB
    Execution times under load test:
  • min 3815ms -> 832ms
  • median 8062ms ->2281ms
  • max 12332ms ->3859ms

from citizenos-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.