11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 34 • MYSQL VIEWSwww.it-ebooks.infoThis returns:+------------+-----------+-------------------+-------------+| First Name | Last Name | Email Address | Telephone |+------------+-----------+-------------------+-------------+| Bob | Connors | bob@example.com | 2125559945 || Jason | Gilmore | jason@example.com | 2125551212 || Matt | Wade | matt@example.com | 2125559999 |+------------+-----------+-------------------+-------------+Using the ALGORITHM AttributeALGORITHM = {MERGE | TEMPTABLE | UNDEFINED}Using this <strong>MySQL</strong>-specific attribute, you can optimize <strong>MySQL</strong>’s execution of the view via threesettings, which are introduced next.MERGEThe MERGE algorithm causes <strong>MySQL</strong> to combine the view’s query definition with any other clauses passedin when executing the view. For example, suppose that a view named employee_contact_info_view wasdefined using this query:SELECT * FROM employees ORDER BY first_name;However, the following statement was used to execute the view:SELECT first_name, last_name FROM employee_contact_info_view;The MERGE algorithm would actually cause the following statement to execute:SELECT first_name, last_name FROM employee_contact_info_view ORDER by first_name;In other words, the view’s definition and the SELECT query have been merged.TEMPTABLEIf the data found in a view’s underlying table changes, the changes will be reflected immediately by wayof the view the next time the table is accessed through it. However, when working with particularly largeor frequently updated tables, you might first consider dumping the view data to a TEMPORARY table tomore quickly release the view’s table lock.When a view is assigned the TEMPTABLE algorithm, a corresponding TEMPORARY table is created atthe same time that the view is created.664

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!