Read about how to optimize sql query using execution plan, The latest news, videos, and discussion topics about how to optimize sql query using execution plan from alibabacloud.com
Say something about the SQL Server execution plan, first of all I'm not a DBA, and I've done some things about SQL optimization in the last few years, and there's something that I understand, and that's not necessarily true. The difference between the T-SQL statement and the
the same value, re-test after rebuilding the index
UPDATE _t SET c = ' 10100 ' WHERE c >= ' 10100 ' and C ' 11000 'ALTER INDEX ix_c on _t REBUILD;
GO SET showplan_all onGOSELECT * from _t WHERE c = N' 10005 ';
GO SET showplan_all OFF;
Accordingly, the estimated number of rows is also increasing If we use the correct data type, where C = ' 10005 ', you can always get the correct estimated number of rows.I'm not sure what criteria SQL server uses
of the query, and if there are no indexes in the query or too many rows to scan, you can feel a noticeable delay. Therefore, you need to change the query mode or create a new index. The explain syntax in MySQL can help us rewrite queries, optimize the structure of tables and set up indexes to maximize
aggregation scan and the table scan actually the difference is not big, must say the difference is large, also must see what in the condition is what, later returns the data. In the case of this SQL statement, the efficiency difference is not very large. You can look at the I/O statistics: Table Scan: Clustered Index Scan: This is beyond the scope of this article, the efficiency is not in the context of this article, this article only consider
When optimizing SQL Performance, we often use viewing the execution evolution. The simplest thing is to use Ctrl + L to view the execution plan, however, the first time I saw this interface, my friends may not be able to get started. SQL server uses icons to display the
1.php Execution Time:$begin=Microtime(true);//gets the time that the program started executing//some code here to execute$stop=Microtime(true);//gets the time that the program execution endedList($m 0,$s 0)=Explode(" ",$begin);List($m 1,$s 1)=Explode(" ",$stop);$runtime=($s 1+$m 1-$s 0-$m 0) *1000;Echo' $etime-$stime.‘ microseconds; 2.SQL
(1) Try to select smaller columns;(2) to index the more frequent fields in where;(3) Avoid using * in select;(4) Avoid the use of calculations, not-in and (5) Use limit1 when only one row of data is needed;(6) To ensure that the single-table data does not exceed 200w, real-time partition table;For a slow query, you can use explain to analyze the statement's specific execution.How do you describe how
Empno,ename,category from emp WHERE empno = ' 7369 'Instead of using the SELECT * from emp WHERE empno = ' 7369 '
9. Sorting Avoid the use of resource-intensive operations, SQL statements with Distinct,union,minus,intersect,order by will start the SQL engine execution, resource-intensive sorting (sort) fu
This article follows: SQL Server execution Plan operator detailed (1)-Assertion (Assert)Objective:According to the plan, this article began to tell the other operator concatenation (concatenation), the reader can be based on the word (both English and Chinese) first fantasy is what it is. In fact, it is very intuitive,
Knowledge Popularization:
1 normally, we use the explain plan for, set autotrace, and utlxplan methods to view the execution plans. They are all the execution plans generated by optimizer and do not fully conform to the execution paths of Oracle internal SQL statements.
2
ArticleDirectory
1. Example of replacing inner join with exists:
When using exists, if you can use it correctly, it may increase the query speed:
1. Replace inner join with exists
2. Replace in with exists
1. Example of replacing inner join with exists:
When writing SQL statements, you may encounter the following statements:
When two tab
Hive provides an explain command that shows the execution plan for a query. The syntax for this statement is as follows:
EXPLAIN [EXTENDED] query
Hive> explain select a. Bar, count (*) from invites a where a. Foo> 0 group by A. bar;
OKAbstract syntax tree:(Tok_query (tok_from (tok_tabref (tok_tabname invites) A) (to
Switching-Different SQL Plan with SQL profiles in Oracle ...
When SQL is generated dynamically by a business system, or is generated by a third-party system, it may be difficult to modify the business program to improve execution pl
different child cursors of the same statement.Note: Another useful view is v$sql_plan_statistics, which provides execution statistics for each operation in the execution plan for each cached cursor. In addition, the V$sql_plan_statistics_all view connects the information in the V$sql_plan with the execution statistics
Here, I learned a very important thing is to use PL/SQL developer to see the execution plan of a SELECT statement, the execution plan can see the cost of this SELECT statement,I/O operation cost and other values, You can clearly see the
driver plays a vital role in the execution performance of the final query statement. Because they determine the maximum data range of the final query results and whether they can obtain the data within this range as quickly as possible, the filter query condition only filters data from the data range determined by the
Label:Previously on the 10g database, if the binding snooping caused the execution plan is slow, want to clear the execution plan of a SQL, let it hard parsing, for a long time did not find a direct operation share pool method (total cannot alter system flush Shared_pool),
exists (select 1From acc. t_base_account BWhere B. account = c. account_noAnd B. currence_code = c. currencycode)And a. account_number is not nullAnd c. account_no like '0%'Group by d. explanation, -- Financial Institution ID codeC. account_no, -- transaction accountA. batchentrydate, -- date of occurrenceC. currencycode, -- currencyC. Ccyledgerbalance-system organization code
Observe and analyze the execution pl
The next article is to record their own blind spots, but also reveal their own development process (may not be developed, can only be said to be blind). Of course, some blind spots are also in the process of work and exploration slowly some, now also willing to carry forward the dedication of the blog park, to come out and share with you.At the beginning of the work, always with their own "high-tech" work, and feel special, often in front of others to say something to make others feel tall on th
the SQL execution plan:
ID
Select_type
Table
type
Possible_keys
Key
Key_len
ref
rows
Extra
1
Simple
T
Range
PRIMARY
PRIMARY
24
299392
Using index condition;
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.