Alibabacloud.com offers a wide variety of articles about steps to optimize sql query, easily find your steps to optimize sql query information here online.
the other hand:SELECT LastName, FirstName, COUNT (*)From NewyorkcitycensusGROUP by LastName, FirstNameCan lead to a large number of groups, each group needs its own memory space, may consume too much memory, hash becomes the bad technique to solve the query.For more information about query plan hashing, visit http://msdn.microsoft.com/en-us/library/ms189582.aspx.SortIf the data is not pre-categorized (indexed), and if
statements. Using adbc in the abap environment is similar to using JDBC in the Java environment.
The reports and transactions they write can use any available interface to access the database.
Use DB2 parameters in SAP Open SQL
SAP supports a batch of DB2 parameters that can be added to Open SQL statements to affect how natural SQL statements generated from Open
50 tips for optimizing query: (see which one is suitable for you)
1. Place data, logs, and indexes on different I/O devices to increase the reading speed. In the past, tempdb can be placed on raid0, which is not supported by SQL2000. The larger the data size (size), the more important it is to increase I/O.
2. vertically and horizontally split the table to reduce the table size (sp_spaceuse)
3. upgrade hardware
4. Create an index based on the
OverviewHow do you write SQL query statements that are relatively high performance? Two methods: Create a reasonable index; write efficient SQL statementsFundamentals of IndexingThe index is divided into clustered and nonclustered indexes. A table can only create one clustered index and n nonclustered indexes, the origin of which is mainly due to the principle of
identify and debug these statements. DMV listed earlier can help identify problematic queries directly.
Below are some basic query statements used to identify these problematic queries:
Excessive recompilation:
selecttop25
sql_text.text,
sql_handle,
plan_generation_num,
execution_count,
dbid,
objectid
from
sys.dm_exec_query_statsa
crossapplysys.dm_exec_sql_text(sql_handle)assql_text
where
plan_generation_num>1
shrinkfile. set to automatically contract logs. For large databases, do not set Automatic database growth, which will reduce the server performance.
The writing of T-SQL is very important. The following lists common points: first, the process of DBMS processing the query plan is as follows:
1. query statement lexical and syntax check 2. submit the statement to t
. Hashing is a technique that can use a lot of memory, but is often more efficient than sorting. When performing different federation, connection operations, and hash advantage sorting, individual rows can be passed to the next operation without having to wait for all incoming row hashes. However, any aggregation value that must be read before the calculated grouping aggregates all input rows can be passed to the next operation.SortIf the data is not pre-categorized (indexed),
record where substring (card_no, 5378) = '20140901'(13 seconds)Select * from record where amount/30 (11 seconds)Select * from record where convert (char (10), date, 112) = '20140901'(10 seconds)Analysis:Any operation results on the column in The WHERE clause are calculated by column one by one during SQL Execution. Therefore, it has to perform table search without using the index on the column; if these results are obtained during
the table vertically and horizontally to reduce the table size (sp_spaceuse) 3) upgrade hardware 4) Create an index based on the query conditions, optimize the index, optimize the access mode, and limit the data volume of the result set. Note that the fill factor should be appropriate (preferably the default value 0 ). The index should be as small as possibl
Label:It is understood that the vast majority of developers understand the index is smattering, limited to the majority of daily work without opportunities, and what is not necessary to care about the index, it is a query is too slow to find the query criteria to build an index OK, which day and a query slow, and then build an index is, Or simply the entire
Tag:seltable match representation where Call dep actuator exp 1, what is the MySQL execution plan to have a better understanding of the implementation plan, you need to first have a simple understanding of MySQL infrastructure and query fundamentals. MySQL's own functional architecture is divided into three parts, namely the application layer, the logical layer, the physical layer, not just MySQL, most of the other database products are divided acco
1, what is the MySQL execution plan to have a better understanding of the implementation plan, you need to first have a simple understanding of MySQL infrastructure and query fundamentals. MySQL's own functional architecture is divided into three parts, namely the application layer, the logical layer, the physical layer, not just MySQL, most of the other database products are divided according to this architecture. The application layer is primarily r
Label:There are three basic types of joins: Cross joins, Inner joins, and outer joins. The cross join has only one step-cartesian product; There are two steps in the inner join-Cartesian product, filtering, outer join has three steps-cartesian product, filtering, adding outer row.Inner joinsCode: SELECT e.empid, E.firstname, E.lastname, O.orderid
from as E
JOIN as O
on = O.empid; Another way to
knows that the data already satisfies our sorting requirements.In fact, using indexes to optimize SQL with sorted requirements is a very important optimization method.Extended reading: MySQL order by implementation analysis, MySQL in the GROUP by the basic principle of implementation and MySQL DISTINCT Basic principles of implementation of these 3 articles have a more in-depth analysis, especially the firs
Three common causes of poor SQL query statement performance and Optimization Methods
1. Reasons for affecting SQL Performance
There are many factors that affect SQL performance, such as incorrect initialization parameter settings and inaccurate system statistics imported, thus affecting the proper judgment of the progr
of the preceding two statements is the same, because the two statements are indeed different from the statement sequence. If tID is an aggregate index, then, the next sentence can only be searched from the 10000 records in the table, while the previous sentence should first look up from the full table to see how many names = 'hangsan, then, the query results are presented based on the condition tID> 10000.In fact, such a worry is unnecessary.
outer join Cartesian product for two tables, on filtering, adding external rows 2. Syntax Only ANSI SQL-92 Syntax Use between table namesLeft OUTER JOIN orRight OUTER JOIN orFull OUTER JOIN orFiltering in the on clause 3. External Connection Basics (1)The left keyword identifies the drive reservation of the table on the right, and the Word keyword indicates that the row is reserved, and the fullkeyword indicates that the rows on both sides of the ta
maintain consistent performance.
The syntax change tells the optimizer to ignore all parameter values, just determine optimize for unknown and omit the parentheses and variable names. Determining optimize for will cause Parametercompiledvalue to disappear from the Showplan XML output, just as parameter sniffing (sniffing) did not occur. Regardless of the parameters passed, the final plan will be the same,
to be linked.
ON: Specifies the fields shared by these tables.
Specify the connection conditions based on the primary key and external key of the table.
The ANSI link syntax is as follows:
SELECT table_name.column_name, table_name.column_name ,......
FROM {table_name [join_type] JOIN table_name ON search_conditions}
WHERE [search_conditions]
[Join_type] can be in the following three keywords:
INNER (inner join): the link query result contains only th
ZWOMILBSM0 l on L.tlntcode=t1.tlntcode join ZWOMEXPRM0 CP on T1.TLNTCODE=CP.T Lntcode where IsNull (T2.DELETEFG, ' 0 ') = ' 0 ' and I.mlbscode in (select value from #i) and i.locatype= '--and i.mlbs Type= ' and P.mlbscode in (select value from #p) and p.locatype= '--and p.mlbstype= ' + l.mlbscode in (select V Alue from #l) and l.locatype= ""--and l.mlbstype= ' and cp.companyn like '% ' [emailprotected]+ '% ' and CP. Sequence=0 ' EXEC sp_executesql @Sql
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.