Database must-know vocabulary: ad-hoc query (Ad Hoc)

Ad hoc query (Ad
Hoc) means that users can flexibly select query conditions according to their own needs, and the system can generate corresponding statistical reports according to the user's selection. The biggest difference between ad hoc query and ordinary application query is that ordinary application query is custom-developed, while ad hoc query is defined by user-defined query conditions.

AD-HOC: The query executed in the form of a separate SQL statement is an ad hoc query , for example: the SQL statement embedded in the C# program, or the SQL code typed in the new query window in SSMS is an ad hoc query.

Putting the SQL code into the stored procedure, the query executed by the stored procedure or function or trigger is not an ad hoc query, ad hoc: on the spot, that is, to query on the spot.

Ad hoc queries refer to those queries that users define according to their needs at that time when they use the system. There are many ways to generate ad hoc queries, the most common one is to use ad hoc query tools . General data display tools will provide ad hoc query functions. The usual way is to map the dimension tables and fact tables in the data warehouse to the semantic layer, and users can select tables through the semantic layer, establish associations between tables, and finally generate SQL statements. There is no essential difference between an ad hoc query and a normal query in terms of SQL statements . The difference between them is that common queries are known during system design and implementation, so we can optimize these queries through indexing, partitioning and other technologies during system implementation to make these queries very efficient. Ad hoc query is a loose type of command/query that is temporarily produced by the user when using it, and its value depends on a certain variable. Every time the command is executed, the result is different, depending on the value of the variable. It cannot be predetermined and usually belongs to dynamic programming SQL queries. Ad hoc queries are short-lived and created at runtime. The system cannot pre-optimize these queries, so ad-hoc queries are also an important indicator for evaluating data warehouses.

The location of ad hoc query is usually in the relational data warehouse, that is, in EDW or ROLAP. Multidimensional databases have their own storage methods, and there is no difference between ad hoc queries and normal queries. In a data warehouse system, the more ad hoc queries are used, the higher the requirements for the data warehouse, and the higher the requirements for the symmetry of the data model. The symmetric data model is the same for all queries, which is also an advantage of dimensional modeling.

Guess you like

Origin blog.csdn.net/weixin_44976611/article/details/129276176