Why does the same SQL query perform differently with different parameters?
In PostgreSQL, an application executes a prepared query that looks up orders by customer_id. One customer gets a response in milliseconds, while another has to wait several seconds. Sometimes the execution time changes after a few runs. Explain how the distribution of orders across customers and PostgreSQL's choice between generic and custom plans can affect performance. How would you test your hypothesis without risking a slowdown for other queries?
ExplainEXPLAIN and optimizationSeniorBackendData Engineer