How to change count method query? #3616
-
I'm working with paginate and I realized that the count(*) method is too slow for the amount of data I have, I would like to run this query to count the data, could I change the method that calls the paginate count? SELECT reltuples AS estimate FROM pg_class WHERE relname = 'table_name'; I want that when I call builder.paginate(page,itemsPerPage) internally call my custom count query, got it? Default count is too slow there is more than 900k data in the table |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
You can add a method to the model query builder like this: https://jagr.co/lessons/how-to-add-a-custom-method-to-the-model-query-builder-in-adonisjs Otherwise just use a raw query : |
Beta Was this translation helpful? Give feedback.
You can add a method to the model query builder like this: https://jagr.co/lessons/how-to-add-a-custom-method-to-the-model-query-builder-in-adonisjs
Otherwise just use a raw query :
https://docs.adonisjs.com/reference/database/query-client#raw-query