Switched to bookshelf count in getTotalMembers()
no issue - tested performance between knex raw, knex `count()` and bookshelf `count()` and found no difference over 1000 iterations of each (each ~19,500ms +- 500ms for 104k members locally) - switched to using bookshelf as the code is the simplest
This commit is contained in:
parent
a995e9cc89
commit
f30d3cd2c2
@ -1,13 +1,10 @@
|
||||
const config = require('../../../shared/config');
|
||||
const db = require('../../data/db');
|
||||
const models = require('../../models');
|
||||
const errors = require('@tryghost/errors');
|
||||
|
||||
// Get total members direct from DB
|
||||
// @TODO: determine performance difference between this, normal knex, and using the model layer
|
||||
async function getTotalMembers() {
|
||||
const isSQLite = config.get('database:client') === 'sqlite3';
|
||||
const result = await db.knex.raw('SELECT COUNT(id) AS total FROM members');
|
||||
return isSQLite ? result[0].total : result[0][0].total;
|
||||
return models.Member.count('id');
|
||||
}
|
||||
|
||||
module.exports = async () => {
|
||||
|
Loading…
Reference in New Issue
Block a user