query
/ˈkwɪə.ri/noun
A query is a targeted instruction to a system to retrieve, filter, combine or modify data.
The query retrieves all outstanding invoices for this month.
A query describes which data a user or application needs. The system processes the instruction and returns a result. Queries are particularly common in Glossary · In briefdatabaseA database is a structured collection of data that software can store, retrieve and modify. A database management system controls access to that data.Read more, search engines and Glossary · In briefAPIAn API is a defined way for software to exchange data or call functions in other software without needing to know how that software works internally.Read more.
What does a query do?
A query can select data based on conditions. An online shop might request all available shoes in size 42, sorted by price. Queries can also add, update or delete data. The available operations depend on the system and query language.
Relational databases often use Glossary · In briefSQLSQL is a language for querying and managing data in a relational database and defining that database's structure.Read more. A developer specifies which table holds the data, which conditions it must meet and how to sort the result. A search engine uses different syntax, but the principle remains the same: the query defines what the system should find or do.
Queries in an application
Users usually do not write technical queries themselves. They select a search term or filter on a screen. The application turns that input into an instruction for the database, search engine or API.
In GraphQL, such an instruction is also called a query. The client specifies the fields it needs. This differs from an SQL query, which operates directly on a relational database. In both cases, the query determines which data is processed. An unnecessarily broad or complex query can take more time and computing resources.