4 ms·
Of course it depends on the exact circumstances, but your query would probably be faster as `SELECT COUNT(*)` than the `LIMIT 1` you optimize to now. In fact, t
by psadauskas 8y ago
Of course it depends on the exact circumstances, but your query would probably be faster as `SELECT COUNT(*)` than the `LIMIT 1` you optimize to now. In fact, that’s one of the specific optimizations mentioned in the article.
- adamzochowski 8y agocount(*) ends up counting all records, reading one first row is much much faster than finding and counting all. https://wiki.postgresql.org/wiki/Slow_Counting https://wiki.postgresql.org/wiki/Slow_Counting
- unilynx 8y agoThat depends a lot on the implementation of the database and the communication protocol. In our case, that made no difference