Queries per second

Also known as: QPS

On this page 7

Queries per second (QPS) is the number of queries a database system completes in one second, measured over a defined interval and workload. In database performance work, QPS is the most common throughput metric: it tells engineers how much load a server or cluster handles now and how close it is to its capacity limit.

QPS is meaningful only together with latency and the query mix. A server that answers 50,000 primary-key lookups per second may manage only a few hundred analytical queries per second, so a QPS figure without context says little about real performance in databases.

How queries per second is measured

QPS is calculated by dividing completed queries by elapsed time, usually from counters that the database engine increments for every statement. Monitoring systems sample a cumulative counter at fixed intervals and compute the rate between samples, typically every 10 to 60 seconds.

Different engines expose different counters, and they do not always count the same things. The table below lists typical sources.

DatabaseCounter or viewWhat it counts
MySQLQuestions and Queries status variablesClient statements, optionally including stored routine statements
PostgreSQLpg_stat_statements calls columnExecutions per normalized statement
SQL ServerBatch Requests/sec performance counterBatches, which may contain many statements
MongoDBopcounters in serverStatusInserts, queries, updates, deletes and commands
Redisinstantaneous_ops_per_secCommands of every type
Typical sources of QPS counters

The averaging window matters. A one-minute average can hide a ten-second burst that saturated the server, so capacity analysis also needs peak QPS at short intervals and percentiles rather than means alone.

QPS, TPS and latency

QPS describes how much work the system completes, while latency describes how long each piece of work takes. The two are linked by Little’s law: the average number of queries in flight equals throughput multiplied by average response time. At 2,000 QPS with a 5 ms average latency, about 10 queries are executing at any moment.

The related metrics below are often reported together and are easy to confuse.

MetricUnitWhat it answers
Queries per secondStatements per secondHow much query load arrives and completes
Transactions per secondCommitted transactions per secondHow many business operations finish
Query latencyMilliseconds, often p95 or p99How long a typical or slow query takes
ConcurrencyActive sessions or queriesHow many requests compete for resources
Error rateFailed queries per secondWhether added throughput is real or failing
QPS and related performance metrics

A transaction often contains several queries, so TPS is usually lower than QPS. Standard benchmarks such as the TPC benchmarks report transaction rates precisely because individual statement counts depend heavily on application design.

What limits achievable QPS

Achievable QPS is set by the scarcest resource per query, whether that is CPU time, disk reads, lock waits or network round trips. When load rises toward that limit, queues form and latency grows sharply before throughput reaches its ceiling.

BottleneckSymptomTypical remedy
CPU saturationHigh CPU, rising latency at flat QPSQuery optimization, better indexes, more cores
Disk I/ORead waits, low buffer pool hit ratioMore memory, faster storage, covering indexes
Lock contentionMany sessions waiting on the same rowsShorter transactions, different isolation level
Connection overheadThousands of short connectionsConnection pooling
Network round tripsLow server load but slow clientsBatching, fewer chatty queries
Common bottlenecks and their symptoms

Application patterns can inflate QPS without adding useful work. The N+1 query problem, for example, turns one page view into hundreds of small queries, so a high QPS figure can signal inefficiency rather than success.

Scaling strategies affect read and write throughput differently. Read replicas and caching multiply read QPS almost linearly, while write QPS is bound by the primary node, its log flush rate and replication overhead. Raising write throughput beyond one node usually requires partitioning or sharding, which spreads writes across independent servers at the cost of more complex queries and transactions.

Using QPS for capacity planning

Capacity planning uses QPS to estimate how much headroom remains before latency targets are breached. Engineers load test the system with a realistic query mix, increase QPS step by step and record the point where p99 latency exceeds the service objective.

A common rule is to keep sustained load at 50 to 70 percent of the measured maximum, leaving room for traffic spikes, failover and maintenance jobs. If one node of a replicated cluster fails, the remaining nodes must absorb its share of QPS, so peak load per node after a failure is the figure that counts.

  • Measure with production-like data, because small test tables fit in memory and overstate QPS.
  • Separate read and write QPS, since reads scale with read replicas while writes usually do not.
  • Track QPS per query fingerprint to see which statements dominate the load.
  • Watch QPS and latency together; rising QPS with stable latency means the system still has margin.

Common misreadings of QPS figures

QPS numbers are frequently quoted without the conditions that produced them, which makes comparisons between systems unreliable. Vendor benchmarks often use tiny rows, warm caches and simple lookups that real applications rarely match.

Another frequent mistake is treating higher QPS as always better. A query cache or an aggressive retry loop can raise the count while users wait longer, and failed queries may still be counted. Reliable reports therefore state the workload, data size, concurrency and latency percentile next to every QPS value.

In simple terms

Queries per second is a count of how many questions a database answers every second. Think of a busy café counting how many orders it serves per minute. The number shows how much work gets done.

It does not show how long each customer waited. A café can serve many simple coffees quickly but far fewer complicated meals. In the same way, QPS only makes sense next to waiting time and the kind of queries being asked.

A practical example

An online retailer prepares for a seasonal sale. Its product database normally handles about 8,000 QPS at peak, with p99 latency of 12 ms. Load tests with a copy of production data show that latency stays under the 50 ms objective up to about 22,000 QPS and then climbs steeply.

Marketing expects traffic to triple, which would mean roughly 24,000 QPS, beyond the safe limit. The team finds that the product page issues a separate query for every review, an N+1 pattern, and replaces it with one joined query. Peak QPS falls by about 40 percent for the same traffic, and two additional read replicas give further headroom. During the sale the database peaks near 15,000 QPS with p99 latency below 20 ms.