Performance testing Common SQL Tips _oracle

Source: Internet
Author: User

For a period of time performance test, put oneself in the performance test process, use the Oracle used in the SQL statement to organize, do a memo;

(1) Multiple fields are spliced in some format

"||" string concatenation characters;

Example: concatenation of "id" and "code" with commas: select T.id| | ', ' | | T.code from otable t;

Note: MySQL uses the concat () function, select Concat (t.id, ', ', t.code) from mtable t;

(2) Count the number of dimensions in a field

Count + GROUP by;

Example: Statistics on the number of data for a creator: select T.creatorname,count (1) from otable t (where you omit the Where Condition query) group by T.creatorname;

(3) Statistics of the number of data generated per second and sorted by quantity from large to small-----------results are often used to determine the reference value of the performance test target TPS;

Count + GROUP by + order by; (Modify the format of TO_CHAR in the following SQL to modify the precision to min or hour)

Example: Select To_char (t.createtime, ' yyyy-mm-dd hh24:mi:ss '), COUNT (1) from otable t where

To_char (T.createtime, ' yyyy-mm-dd hh24:mi:ss ') >= ' 2016-01-01 00:00:00 ' and

To_char (T.createtime, ' yyyy-mm-dd hh24:mi:ss ') <= ' 2016-12-31 23:59:59 '

Group BY To_char (T.createtime, ' yyyy-mm-dd hh24:mi:ss ')

Order by count (1) desc;

MySQL Implementation method:

date_format+ GROUP by + order by; (Modify the second parameter in the Date_format to modify the precision to min or hour)

Example: Select Date_format (start_time, '%y%m%d%h%i%s ') Isecond,count (ID) as icount from Mtable t where

T.start_time between ' 2017-06-01 00:00:00 ' and ' 2017-06-01 23:59:59 '

GROUP BY Isecond

ORDER BY icount Desc;

Performance testing Common SQL Tips _oracle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.