Mysql:Changes in MySQL 5.6.4 (2011-12-20, Milestone 7):微秒支持、Innodb全文索引支持
Changes in MySQL 5.6.4 (2011-12-20, Milestone 7)
-
Incompatible Change: MySQL now permits fractional seconds for
TIME,DATETIME, andTIMESTAMPvalues, with up to microseconds (6 digits) precision. To define a column that includes a fractional seconds part, use the syntax, wheretype_name(fsp)type_nameisTIME,DATETIME, orTIMESTAMP, andfspis the fractional seconds precision. For example:CREATE TABLE t1 (t TIME(3), dt DATETIME(6));
The
fspvalue, if given, must be in the range 0 to 6. A value of 0 signifies that there is no fractional part. If omitted, the default precision is 0. (This differs from the standard SQL default of 6, for compatibility with previous MySQL versions.)The following items summarize the implications of this change. See also Fractional Seconds in Time Values.
-
For
TIME,DATETIME, andTIMESTAMPcolumns, the encoding and storage requirements in new tables differ from such columns in tables created previously because these types now include a fractional seconds part. This can affect the output of statements that depend on the row format, such asCHECKSUM TABLE. -
Due to these changes in encoding and storage requirements for MySQL's
DATETIMEandTIMESTAMPtypes, importing pre-MySQL 5.6.4InnoDBtables usingALTER TABLE ... IMPORT TABLESPACEthat containDATETIMEandTIMESTAMPtypes into MySQL 5.6.4 (or later) requires a workaround procedure which is described in the “Server Changes” section of Changes in MySQL 5.6 . -
Syntax for temporal literals now produces temporal values:
DATE ',str'TIME ', andstr'TIMESTAMP ', and the ODBC-syntax equivalents. The resulting value includes a trailing fractional seconds part if specified. Previously, the temporal type keyword was ignored and these constructs produced the string value. See Standard SQL and ODBC Date and Time Literalsstr' -
Functions that take temporal arguments accept values with fractional seconds. Return values from temporal functions include fractional seconds as appropriate.
-
Three
INFORMATION_SCHEMAtables,COLUMNS,PARAMETERS, andROUTINES, now have aDATETIME_PRECISIONcolumn. Its value is the fractional seconds precision forTIME,DATETIME, andTIMESTAMPcolumns, andNULLfor other data types. -
The C API accommodates fractional seconds as follows:
-
In the
MYSQL_FIELDcolumn metadata structure, thedecimalsmember indicates the fractional seconds precision forTIME,DATETIME, andTIMESTAMPcolumns. Clients can determine whether a result set temporal column has a fractional seconds part by checking for a nonzerodecimalsvalue in the correspondingMYSQL_FIELDstructure. Previously, thedecimalsmember indicated the precision for numeric columns and was zero otherwise. -
In the
MYSQL_TIMEstructure used for the binary protocol, thesecond_partmember indicates the microseconds part forTIME,DATETIME, andTIMESTAMPcolumns. Previously, thesecond_partmember was unused.
-
In some cases, previously accepted syntax may produce different results. The following items indicate where existing code may need to be changed to avoid problems:
-
Some expressions produce results that differ from previous results. Examples: The
timestampsystem variable returns a value that includes a microseconds fractional part rather than an integer value. Functions that return a result that includes the current time (such asCURTIME(),SYSDATE(), orUTC_TIMESTAMP()) interpret an argument as anfspvalue and the return value includes a fractional seconds part of that many digits. Previously, these functions permitted an argument but ignored it. -
TIMEvalues are converted toDATETIMEby adding the time to the current date. (This means that the date part of the result differs from the current date if the time value is outside the range from'00:00:00'to'23:59:59'.) Previously, conversion ofTIMEvalues toDATETIMEwas unreliable. See Conversion Between Date and Time Types. -
TIMESTAMP(was permitted in old MySQL versions, butN)Nwas a display width rather than fractional seconds precision. Support for this behavior was removed in MySQL 5.5.3, so applications that are reasonably up to date should not be subject to this issue. Otherwise, code must be rewritten.
NoteThere may be problems replicating from a master server that understands fractional seconds to an older slave that does not:
-
For
CREATE TABLEstatements containing columns that have anfspvalue greater than 0, replication will fail due to parser errors. -
Statements that use temporal data types with an
fspvalue of 0 will work for with statement-based logging but not row-based logging. In the latter case, the data types have binary formats and type codes on the master that differ from those on the slave. -
Some expression results will differ on master and slave. For example, expressions that involve the
timestampsystem variable or functions that return the current time have different results, as described earlier.
(Bug #8523, Bug #11745064)
-
-
MySQL now supports
FULLTEXTindexes forInnoDBtables. The core syntax is very similar to theFULLTEXTcapability from earlier releases, with theCREATE TABLEandCREATE INDEXstatements, andMATCH() ... AGAINST()clause in theSELECTstatement. The new@operator allows proximity searches for terms that are near each other in the document. The detailed search processing is controlled by a new set of configuration options:innodb_ft_enable_stopword,innodb_ft_server_stopword_table,innodb_ft_user_stopword_table,innodb_ft_cache_size,innodb_ft_min_token_size, andinnodb_ft_max_token_size. You can monitor the workings of theInnoDBfull-text search system by querying newINFORMATION_SCHEMAtables:innodb_ft_default_stopword,innodb_ft_index_table,innodb_ft_index_cache,innodb_ft_config,innodb_ft_deleted, andinnodb_ft_being_deleted.
-
Performance; InnoDB: New optimizations apply to read-only
InnoDBtransactions. See Optimizing InnoDB Read-Only Transactions for details. The new optimizations make autocommit more applicable toInnoDBqueries than before, as a way to signal that a transaction is read-only because it is a single-statementSELECT. -
Performance; InnoDB: You can now set the
InnoDBpage size for uncompressed tables to 8KB or 4KB, as an alternative to the default 16KB. This setting is controlled by theinnodb_page_sizeconfiguration option. You specify the size when creating the MySQL instance. AllInnoDBtablespaces within an instance share the same page size. Smaller page sizes can help to avoid redundant or inefficient I/O for certain combinations of workload and storage devices, particularly SSD devices with small block sizes.
浙公网安备 33010602011771号