Parameters

SettingValue
DatabaseSQLite 3.50.4 (64-bit)
OSArch Linux x86_64
CPUAMD Ryzen 5 6600H
Table Rows100,000

Experiment

  1. Create a database with random values (100,000 rows) using Python
  2. Run query 30 times to avoid cold start bias

Results

The chart compares query execution times between COUNT(*) and COUNT(column_name):

COUNT Comparison

Conclusion

In places where NULL values aren't an issue, COUNT(*) is the preferred counting method for efficiency in SQLite.

💡 Key Takeaway: Use COUNT() when you want the total count of rows regardless of NULL values. Use COUNT(column_name) only when you need to count only non-NULL values in that specific column. For maximum efficiency in SQLite, prefer COUNT().