Query
PronunciationKWEER-ee
Definition
A request to the database to read or change data, usually written in SQL. A query can be simple, such as selecting one column from a table, or complex, with joins and filters. Slow queries are a common cause of slow pages.
Where you hear it
Performance work: "this query is slow".
Examples
Run this query to find all unpaid invoices.
The query takes 8 seconds because there is no index.
The query joins orders with customers, then filters the ones from last month.
Common mistake
Building queries by joining strings with user input. That opens the door to SQL injection; use parameters.
Don't confuse with
Query is often confused with Command; a query is typically used to retrieve data without changing it, while a command is used to modify the state or structure of the database.
Say it at work
- In a meeting or chat
Could you take a look at this query and see if there is any way to optimize it?
- In an email or ticket
I have updated the query in the latest commit to include the new join condition.