variable is still unknown and thus cannot be used as an input for index selection. The following statement performs a full table scan:Select id from t where num = @ numYou can change it to force query to use the index:Select id from t with (index name) where num = @ num
7. Avoid performing expression operations on fields in the where clause as much as possible, which will cause the engine to discard the use of indexes for full table scanning. For example:SELECT * FROM T1 WHERE F1/2 = 100Should
Oracle performance optimization operation 1: Avoid Column Operations
Any operation on a column may cause a full table scan. Here, the so-called operations include database functions, calculation expressions, and so on. During query, try to move the operation to the right of the equation,Even Remove functions.
Example 1: the columns in the following SQL condition statements have an appropriate index, but the execution speed is very slow when there are 0.3 million rows of data:
Select * from re
(55 seconds)
Select count (*) from record where date> '123' and place in ('bj ', 'sh') (27 seconds)
Select count (*) from record where date> '20160901' and date
Select date, sum (amount) from record group by date (28 seconds)
Select count (*) from record where date> '2013' and place in ('bj ', 'sh') (14 seconds)
Select count (*) from record where date> '20160301' and date
Select date, sum (amount) from record group by date (27 seconds)
Select count (*) from record where date> '2013' and place
, the product is minimized as the best scheme 5. Any action on a column in the WHERE clause results in a column-wise calculation at the SQL runtime, so it has to perform a table search without using the index above the column, and if the results are available at query compile time, it can be optimized by the SQL optimizer, using the index, and avoiding table searches (example: select *fromrecordwheresubstring (card_no,1,4) = ' 5378 ' select*from
, method, member variable, and so on) is obsolete and the compiler will no longer like the use of this labeled program element.If used (either the current class or a class under another package), compilation draws a slash on the program element to indicate that the program element is obsolete.650) this.width=650; "border=" 0 "src=" http://s3.51cto.com/wyfs02/M00/82/92/wKioL1dbj3Dh80sXAAAdPIdRrOM268.png " data_ue_src= "E:\My knowledge\temp\0e1f84ee-5378
"POJ 2409" Let It Bead (Polya)
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 5378
Accepted: 3596
Description"Let It Bead" Company was located upstairs at the Cannery Row in Monterey, CA. As can deduce from the company name, their business is beads. Their PR department found out that customers is interested in buying colored bracelets. However, over-percent of the target audie
beautiful mahjong tree using these rules, because of the answer Can is very large, you need output the answer modulo 1e9 + 7.Inputthe first line of the input was a single integer T, indicates the number of test cases.For each test case, the first line contains an integers n. (1 And the next n-1 lines, each line contains the integers UI and VI, which describes a edge of the tree, and Vertex 1 is The root of the tree.Outputfor each test case, output one line. The output format is ' case #x: ans '
information.For more details, you must use the sa role to execute dbcc (3604,310,302 ).
3. where clause that cannot be optimized1. For example, the columns in the following SQL condition statements have an appropriate index, but the execution speed is very slow:
Select * from record where substring (card_no, 5378) = '000000' (13 seconds)Select * from record where amount/30 Select * from record where convert (char (10), date, 112) = '000000' (10 s
the tables with indexes and tables with multiple rows. The selection of the internal and external tables can be determined by the formula: Number of matched rows in the outer table * Number of times each query is performed in the inner table, the minimum product is the best solution.Unoptimized WHERE clauseExample 1The columns in the following SQL condition statements have an appropriate index, but the execution speed is very slow:SELECT * FROM record WHERE substrINg (card_no,
optimizer will list several possible connection solutions based on the connection conditions and find the best solution with the minimum system overhead. The join conditions must fully consider the tables with indexes and tables with multiple rows. The selection of the internal and external tables can be determined by the formula: Number of matched rows in the outer table * Number of times each query is performed in the inner table, the minimum product is the best solution.
2. view the method o
conventional, set-oriented SQL statements.Statement requires more overhead; extract data searches in a specific order.
2. Avoid using incompatible data types. Such as float and INT, char and varchar, binary, andVarbinary is incompatible. Incompatible data types may make the optimizer unable to execute some operations that can be imported. For example:Select name from employee where salary> 60000In this statement, if the salary field is of the money type, it is difficult for the optimizer to opt
be compiled, use these Cust or target header files to control which tasks will be started by the system after the system starts. Let's seeProducts/76xx/services/TMC. cThe tmc_define_tasks function under can know how many tasks are supported in AMSS. All the functions in more than 4000 rows call the Rex system function.Rex_def_task defines a task. For example, NV:5374 rex_def_task ( nv_tcb,5375 (rex_stack_word_type *) nv_stack,5376 nv_stack_siz,5377 (rex_priority_type) nv_pri,
name) where num = @ num 7. Avoid performing expression operations on fields in the WHERE clause as much as possible, which will cause the engine to discard the use of indexes for full table scanning. For example:Select * from T1 where F1/2 = 100Should be changed:Select * from T1 where F1 = 100*2Select * from record where substring (card_no, 5378) = '20140901'Should be changed:Select * from record where card_no like '201312'Select member_number, first
determined by the formula: Number of matched rows in the outer table * The number of times each query is performed in the inner table. The minimum product is the best solution. ---- 2. How to view the execution plan -- Use Set showplanon , Open Showplan You can see the connection The order of access and the index information to use. For more detailed information, you need SA Role execution DBCC (3604,310, 302) . Iii. unoptimizable Where Clause ---- 1.
as those modules that need to be compiled, through the cust or target header file to control which tasks will be started by the system after the system is started. Let's seeProducts/76xx/services/TMC. in C, the tmc_define_tasks function can know how many tasks are supported in AMSS. All the functions in more than 4000 rows call the rex_def_task function of the Rex system to define tasks. For example, NV:5374 rex_def_task ( nv_tcb,5375 (rex_stack_word_type *) nv_stack,5376 nv_stack_siz,5377 (rex
appropriate index, but the execution speed is very slow:Select * from record whereSubstring (card_no, 5378) = '000000' (13 seconds)Select * from record whereAmount/30 Select * from record whereConvert (char (10), date, 112) = '000000' (10 seconds)---- Analysis:---- Any column operation results in the where clause are calculated by column during SQL Execution, so it hasThe index on the column is not used for table search. If these results are obtained
appropriate index, but the execution speed is very slow:Select * from record whereSubstring (card_no, 5378) = '000000' (13 seconds)Select * from record whereAmount/30 Select * from record whereConvert (char (10), date, 112) = '000000' (10 seconds)---- Analysis:---- Any column operation results in the where clause are calculated by column during SQL Execution, so it hasThe index on the column is not used for table search. If these results are obtained
example, the columns in the following SQL condition statements have an appropriate index, but the execution speed is very slow:
Select * from record where
Substring (card_no, 5378) = '000000' (13 seconds)
Select * from record where
Amount/30 Select * from record where
Convert (char (10), date, 112) = '000000' (10 seconds)
---- Analysis:
---- Any column operation results in the where clause are calculated by column during SQL Execution, so it has
The
(card_no, 5378) = '000000' (13 seconds)Select * from record whereAmount/30 Select * from record whereConvert (char (10), date, 112) = '000000' (10 seconds)---- Analysis:---- Any column operation results in the WHERE clause are calculated by column during SQL Execution, so it hasThe index on the column is not used for table search. If these results are obtained during query compilationIt can be optimized by the SQL optimizer and indexed to avoid table
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.