Giter Site home page Giter Site logo

Comments (1)

ilmartyrk avatar ilmartyrk commented on July 19, 2024

Used http://tatiyants.com/pev/ to visualize result for the query
replaced the

LEFT JOIN (
                            SELECT t.id, MAX(a."updatedAt") as "lastActivity"
                            FROM "Topics" t JOIN "Activities" a ON ARRAY[t.id::text] <@ a."topicIds" GROUP BY t.id
                        ) ta ON (ta.id = t.id)

with
LEFT JOIN "Activities" a ON ARRAY[t.id::text] <@ a."topicIds"
The initial subquery run for all the topics and activities thus adding way more time and weight for the query.

Initial plan time:

1.47
execution time (s)
6.1
planning time (ms)
1.38
slowest node (s)
31,346
largest node (rows)
41,243.52
costliest node

Optimized:

176.72
execution time (ms)
3.69
planning time (ms)
98
slowest node (ms)
17,995
largest node (rows)
12,161.34
costliest node

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.