EventsDB: count by retrieving the rows instead of using COUNT

This commit is contained in:
Alex Gleason 2024-04-08 09:22:52 -05:00
parent 96887483e8
commit 6ee8d4ab47
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -341,15 +341,10 @@ class EventsDB implements NStore {
if (!filters.length) return Promise.resolve({ count: 0, approximate: false });
this.#debug('COUNT', JSON.stringify(filters));
const query = this.getEventsQuery(filters);
const [{ count }] = await query
.clearSelect()
.select((eb) => eb.fn.count('id').as('count'))
.execute();
const results = await this.query(filters);
return {
count: Number(count),
count: results.length,
approximate: false,
};
}