query specifies the result, not the exact computation
multiple alternatives are common with vastly different runtime characteristics So,deciding which alternative to choose is important which is the job of the que ry optimizer. Query optimization is a function of many relational database management systems. The query optimizer attempts to determine the most efficient way to execute a g iven query by considering the possible query plans. Generally, the query optimizer cannot be accessed directly by users: once querie s are submitted to database server, and parsed by the parser, they are then pass ed to the query optimizer where optimization occurs. However, some database engi nes allow guiding the query optimizer with hints. A query is a request for information from a database. It can be as simple as "fi nding the address of a person with SS# 123-45-6789," or more complex like "findi ng the average salary of all the employed married men in California between the ages 30 to 39, that earn less than their wives." Queries results are generated b y accessing relevant database data and manipulating it in a way that yields the requested information. Since database structures are complex, in most cases, and especially for not-very-simple queries, the needed data for a query can be coll ected from a database by accessing it in different ways, through different data- structures, and in different orders. Each different way typically requires diffe rent processing time. Processing times of the same query may have large variance , from a fraction of a second to hours, depending on the way selected. The purpo se of query optimization, which is an automated process, is to find the way to p rocess a given query in minimum time. The large possible variance in time justif ies performing query optimization, though finding the exact optimal way to execu te a query, among all possibilities, is typically very complex, time consuming b y itself, may be too costly, and often practically impossible. Thus query optimi zation typically tries to approximate the optimum by comparing several common-se nse alternatives to provide in a reasonable time a "good enough" plan which typi cally does not deviate much from the best possible result. Structured Query Language (SQL) SQL is a tool for Managing, retrieving, organizing data stored in a computer dat abase. SQL is a nonprocedural language. Nonprocedural means what rather than how. For e xample, SQL describes what data to retrieve, delete, or insert, rather than how to perform the operation. The characteristic that differentiates a DBMS from an RDBMS is that the RDBMS pr ovides a set-oriented database language. For most RDBMSs, this set-oriented data base language is SQL. Set oriented means that SQL processes sets of data in grou ps. The most common operation in SQL, the query, makes use of the declarative SELECT statement. SELECT retrieves data from one or more tables, or expressions. Queries allow the user to describe desired data, leaving the database management system (DBMS) to carry out planning, optimizing, and performing the physical op erations necessary to produce that result as it chooses. A query includes a list of columns to include in the final result, normally imme diately following the SELECT keyword. An asterisk ("*") can be used to specify t hat the query should return all columns of the queried tables. SELECT is the mos t complex statement in SQL, with optional keywords and clauses that include: The FROM clause, which indicates the table(s) to retrieve data from. The FROM cl ause can include optional JOIN subclauses to specify the rules for joining table s. ,the query. The WHERE clause eliminates all rows from the result set where the c omparison predicate does not evaluate to True. The GROUP BY clause projects rows having common values into a smaller set of row s. GROUP BY is often used in conjunction with SQL aggregation functions or to el iminate duplicate rows from a result set. The WHERE clause is applied before the GROUP BY clause. The HAVING clause includes a predicate used to filter rows resulting from the GR OUP BY clause. Because it acts on the results of the GROUP BY clause, aggregatio n functions can be used in the HAVING clause predicate. The ORDER BY clause identifies which column[s] to use to sort the resulting data , and in which direction to sort them (ascending or descending). Without an ORDE R BY clause, the order of rows returned by an SQL query is undefined. The DISTINCT keyword eliminates duplicate data
Python Highway 2 Books in 1 The Fastest Way For Beginners To Learn Python Programming, Data Science and Machine Learning in 3 Days (Or Less) + Practical Exercises Included by Cox, Aaron