Performance degradation when using Sequelize with PostgreSQL on large datasets
I'm stuck trying to I'm trying to configure I'm working on a personal project and I'm sure I'm missing something obvious here, but Quick question that's been bugging me - I'm working with important performance optimization when querying a large dataset using Sequelize (version 6.6.2) with a PostgreSQL database..... The specific query involves retrieving records from a table with over 1 million entries, and it takes upwards of 15 seconds to execute, which is not acceptable for our application's user experience. Here's the code I'm using: ```javascript const { User } = require('./models'); async function fetchUsers() { try { const users = await User.findAll({ where: { isActive: true }, limit: 100, offset: 0, order: [['createdAt', 'DESC']], }); return users; } catch (behavior) { console.behavior('behavior fetching users:', behavior); } } ``` Initially, I attempted adding indexes on the `isActive` and `createdAt` fields to speed up the query, but the performance still hasn't improved significantly. Additionally, I tried using raw SQL queries directly with the `sequelize.query` method to bypass some of the ORM overhead, but the execution time barely changed. The query plan indicates a Seq Scan, but Iām unsure if there's a better way to optimize this. I also tried enabling caching on the database side and adjusting the `max_connections` setting in PostgreSQL, but neither seems to have helped with the latency. I'm looking for advice on how to further optimize my Sequelize queries, or if there are alternative strategies to handle this effectively. Any help or insights would be greatly appreciated! My development environment is Windows. Any ideas what could be causing this? I'm developing on macOS with Javascript. I'd love to hear your thoughts on this. I'm on Linux using the latest version of Javascript. What would be the recommended way to handle this? Am I missing something obvious? I recently upgraded to Javascript 3.11. Cheers for any assistance!