I am using Sequelize with Node for my backend.
One of my tables is probably going to grow a lot in the coming weeks (at this moment, the table is around 1-2M rows).
I added 30M lines and added the right indexes, my perf are even better than the current table with 1M rows and no indexes.
Between 0.00 sec and 0.05 sec for search or insert into the table, using the indexed columns.
My problem is that my back is using the findAndCountAll
function from Sequelize to allow pagination use.
This leads to an API reply time of 20+ seconds, which is not usable.
This is because the 30M rows are making the count(*)
request slow, and no index can help with this.
Anyone already tried a workaround, maybe pagination by any way without using a count(*), or maybe storing the amount of rows in another table ?
Note that the second solution would still create problems since there is a date filter in the paging, so I cannot just store the total amount of results, it depends on the given dates.