当前位置:网站首页>Some small knowledge points
Some small knowledge points
2022-07-01 04:12:00 【speoki】
(1) Use mysql Doing set operations
1. Combine union Union and collection
SELECT product_id, product_name
FROM product
UNION
SELECT product_id, product_name
FROM product2;
2. Difference set not in
SELECT *
FROM Product
WHERE product_id NOT IN (SELECT product_id
FROM Product2)
3. intersection inner join
SELECT p1.product_id, p1.product_name
FROM Product p1
INNER JOIN Product2 p2
ON p1.product_id=p2.product_id
- Symmetry difference
SELECT *
FROM Product
WHERE product_id NOT IN (SELECT product_id FROM Product2)
UNION
SELECT *
FROM Product2
WHERE product_id NOT IN (SELECT product_id FROM Product)
5. Cartesian product cross join
The cartesian product :
SELECT SP.shop_id
,SP.shop_name
,SP.product_id
,P.product_name
,P.sale_price
FROM ShopProduct AS SP
CROSS JOIN Product AS P;
(2)mysql Ways to break the deadlock
Set the timeout for transaction waiting
innodb_lock_wait_timeout
- Enable active deadlock detection
innodb_deadlock_detect
(3) View the latest deadlock information
show engine innodb status
(4)mysql To perform a sql Statement flow
The first step is actually to query the cache , however mysql8 Query cache canceled . Although query caching improves system performance , But the overhead of maintaining the cache is also relatively large
Parsing statements ( Query analysis )
select title from order where id=1
① Lexical analysis Extract keywords , The above sentence sql Will be divided into 8 Parts of
stay elasticsearch The engine also has a dictionary to segment sentences
② Syntax analysis According to the result of lexical analysis , Generate syntax tree ( The parse tree ), Judge sql Whether the statement satisfies the syntax rules .
If there is a syntax error in the statement, it will be displayed at this time ‘You have an error in your SQL syntax’
- Search and check ( The preprocessor )
① Semantic analysis
Form a semantic tree transformed from relational algebra
② Symbol name conversion
Bind variables to definitions in symbol table
If the field name and table name do not exist, an error will be reported UnKnow column ‘abc’ in ‘field list’
③ Safety inspection
- Autonomous access control
- Forced access control
④ Preliminary integrity check
- Referential integrity
- Entity integrity
- User defined integrity
- Query optimization ( Optimizer )
mysql Use an overhead based optimizer , Choose a plan that costs less
mysql By querying the current session last_query_cost To calculate the cost of the current query
see last_query_cost The order of :show status like ‘last_query_cost’
The costs considered may be : Number of pages per table or index , The cardinality of the index , Index and data row length . Index distribution, etc .
The optimization strategies are :
① Redefine the order in which tables are associated , It depends on the size of the watch , Or it is possible to convert an outer connection to an inner connection , The subquery is transformed into a connection
② Optimize to find the maximum and minimum functions
③ Optimization of sorting
…
- Query execution ( actuator )
Generate an execution plan for the execution strategy obtained above , Let the code generator execute the query plan , Take the data from the storage engine and return it to the client
边栏推荐
猜你喜欢

Account sharing technology enables the farmers' market and reshapes the efficiency of transaction management services

[TA frost wolf \u may - "hundred people plan"] 2.1 color space

小程序中自定义组件

【TA-霜狼_may-《百人计划》】1.2.1 向量基础

Custom components in applets

Why can't you find the corresponding function by clicking go to definiton (super easy has a diagram)

Network metering - application layer

Embedded System Development Notes 79: why should I get the IP address of the local network card

Loop filtering based on Unet

Usage of AfxMessageBox and MessageBox
随机推荐
类和对象收尾
【TA-霜狼_may-《百人计划》】1.2.2 矩阵计算
一些小知识点
ThreeJS开篇
431. encode n-ary tree as binary tree DFS
Usage of AfxMessageBox and MessageBox
【发送邮件报错】535 Error:authentication failed
Go learning --- unit test subtest
什么是权限?什么是角色?什么是用户?
Account sharing technology enables the farmers' market and reshapes the efficiency of transaction management services
NFT: utilisez EIP - 2981 pour commencer un voyage de redevances NFT
Quickly filter data such as clock in time and date: Excel filter to find whether a certain time point is within a certain time period
[TA frost wolf \u may- hundred people plan] 1.3 secret of texture
Inventory the six second level capabilities of Huawei cloud gaussdb (for redis)
25.K个一组翻转链表
242. valid Letter heteronyms
206.反转链表
NFT: start NFT royalty journey with eip-2981
Chen Yu (Aqua) - Safety - & gt; Cloud Security - & gt; Multicloud security
Millet College wechat scanning code login process record and bug resolution