Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
admin:optimization:plans:home [2012/02/01 22:15]
doc
admin:optimization:plans:home [2016/06/28 22:38] (current)
Line 3: Line 3:
 {{page>:​top_add&​nofooter&​noeditbtn}} {{page>:​top_add&​nofooter&​noeditbtn}}
  
-====== Administration ======+====== Administration: Optimizing Queries ​======
  
-===== Optimizing Queries ​=====+===== Query Plans =====
  
  
 **[[admin:​optimization:​plans:​home|Overview]]** | **[[admin:​optimization:​plans:​home|Overview]]** |
-[[admin:​optimization:​plans:​sections|Sections]] | +[[admin:​optimization:​plans:​reference|Anatomy of a Query Plan]] | 
-[[admin:​optimization:​plans:​steps|Steps]] | +[[admin:​optimization:​plans:​example|Reading a Query Plan]] | 
-[[admin:​optimization:​plans:​optimized|Fully Optimized ​Queries]]+[[admin:​optimization:​plans:​configuration|Configuring Query Plans]] | 
 +[[admin:​optimization:​plans:​optimization|Optimizing ​Queries]]
  
 ---- ----
-\\+
  
 ==== Overview ==== ==== Overview ====
  
-Omnidex always optimizes a query as well as it can using the Omnidex indexes; however, if the indexes are not enough, Omnidex will complete the query without indexes, insuring the correct result. ​ In fact, Omnidex can process queries even when no Omnidex indexes are available ​at all.  In this way, Omnidex is first and foremost a SQL Engine for both relational and non-relational,​ or NoSQL, databases.  ​+Omnidex always optimizes a query as well as it can using the Omnidex indexes; however, if the indexes are not enough, Omnidex will complete the query without indexes, insuring the correct result. ​ In fact, Omnidex can process queries even when no Omnidex indexes are available. ​ In this way, Omnidex is first and foremost a SQL Engine for both relational and non-relational,​ or NoSQL, databases.  ​
  
-Omnidex will evaluate the query and identify where indexes can be used.  Omnidex evaluates the tables and their join relationships. ​ Omnidex evaluates criteria, including nested queries, SQL functions and complex Boolean operations. ​ Omnidex evaluates ​group by and order by, both to perform aggregations and to avoid unnecessary sorting of data.  Omnidex even considers whether indexes can be used to return columns in the result set, avoiding ​accessing ​the data whenever possible.  ​If there are not indexes to satisfy ​any of these steps, it will process ​then without the aid of indexing.  ​+Omnidex will evaluate the query and identify where indexes can be used.  Omnidex evaluates the tables and their join relationships. ​ Omnidex evaluates criteria, including nested queries, SQL functions and complex Boolean operations. ​ Omnidex evaluates ​GROUP BY and ORDER BY clauses, both to perform aggregations and to avoid unnecessary sorting of data.  Omnidex even considers whether indexes can be used to return columns in the result set, avoiding ​access to the database ​whenever possible.  ​In any of these situations, if there are not indexes to satisfy ​a step, it will process ​that part of the query without the aid of indexing.  ​
  
 The optimization plan for a query shows a sequence of steps, including table joins, processing criteria, aggregating data, and retrieving from the database. ​ The ideal with Omnidex optimization is to avoid retrieving from the database if possible, and to fully optimize the query solely through the Omnidex indexes. ​ If non-indexed steps are required, optimization tries to minimize these steps as much as possible. The optimization plan for a query shows a sequence of steps, including table joins, processing criteria, aggregating data, and retrieving from the database. ​ The ideal with Omnidex optimization is to avoid retrieving from the database if possible, and to fully optimize the query solely through the Omnidex indexes. ​ If non-indexed steps are required, optimization tries to minimize these steps as much as possible.
  
-==== Optimizing ​a Query ====+==== Obtaining ​a Query Plan ==== 
 + 
 +Query plans are produced using the EXPLAIN command in OdxSQL. ​ A plan can be obtain by preceding the SELECT statement with the word EXPLAIN, as shown in the example below: 
 + 
 +<​code>​ 
 +> explain select name, phone, email from individuals;​ 
 +----------------------------------- SUMMARY ----------------------------------- 
 +Select ​       NAME, 
 +              PHONE, 
 +              EMAIL 
 +  from        INDIVIDUALS;​ 
 + 
 +Version: ​     5.2.01 ​ (Compiled Jan 23 2012 17:27:25) 
 +Warnings: ​    ​SEQUENTIAL_SCAN 
 +----------------------------------- DETAILS ----------------------------------- 
 +Retrieve INDIVIDUALS sequentially;​ 
 +Return INDIVIDUALS.NAME,​ INDIVIDUALS.PHONE,​ INDIVIDUALS.EMAIL;​ 
 +------------------------------------------------------------------------------- 
 +</​code>​ 
 + 
 +The EXPLAIN command can also follow a query in OdxSQL. ​ It will provide a query plan for the query that was just executed. ​ This approach has the advantage of having more statistics about the query; however, generating the query plan before the query is run has the advantage of checking a query before it consumes too many resources.
  
-The following is a rather straightforward query that joins two tables together --- Individuals ​and their respective Households --- and aggregates counts ​of all people born since 1980 that are either in DenverCO or in Phoenix, AZ.  The result is a display of counts by Gender. ​ Let's take a look at how Omnidex optimizes this query.  ​+A plan consists of two sections: the Summary ​and the Details. ​ The Summary section shows the SQL statement, the version ​of Omnidexand any optimization warnings ​or suggestions about the query.  The Details section shows the steps that will be executed to satisfy the query.  ​
  
-<​html>​ +In the simple example abovethree columns are retrieved ​from the INDIVIDUALS ​table. ​ Since no criteria was provided in a WHERE clause, the details of the plan show that the table is retrieved sequentially ​and the columns are returned A simple warning indicates that a sequential scan is taking placewhich in this case cannot be avoided.
-<p style="​font:​ courier>​ +
-Select ​   I.GENDERcount(*) <br /> +
-  ​from    ​HOUSEHOLDS H <br /> +
-  join    ​INDIVIDUALS ​ <br /> +
-    on    H.HOUSEHOLD = I.HOUSEHOLD <br /> +
- ​where ​   ((H.STATE = ‘CO’ ​and <br /> +
-            H.CITY = ‘Denver’) or <br /> +
-           ​(H.STATE = ‘AZ’ and <br /> +
-            H.CITY = ‘Phoenix’)) and <br /> +
-          I.BIRTHDATE > ‘January 11980’ <br /> +
-group by  I.GENDER  +
-</​p>​ +
-</​html>​+
    
-[[admin:​optimization:​plans:​home| More >]] 
  
 =====  ===== =====  =====
 ---- ----
 \\ \\
-**[[admin:​optimization:​overview:hdc|Next]]**+**[[admin:​optimization:​plans:reference|Next]]**
  
  
 ====== Additional Resources ====== ====== Additional Resources ======
 See also: See also:
-{{page>:​admin:​indexing:​see_also&​nofooter&​noeditbtn}}+{{page>:​admin:​optimization:​see_also&​nofooter&​noeditbtn}}
  
 {{page>:​bottom_add&​nofooter&​noeditbtn}} {{page>:​bottom_add&​nofooter&​noeditbtn}}
 
Back to top
admin/optimization/plans/home.1328134515.txt.gz · Last modified: 2016/06/28 22:38 (external edit)