当前位置:网站首页>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
边栏推荐
- Inventory the six second level capabilities of Huawei cloud gaussdb (for redis)
- Grid system in bootstrap
- 168. excel table column name
- 8. string conversion integer (ATOI)
- [TA frost wolf \u may- hundred talents plan] 1.2.2 matrix calculation
- [untitled] Li Kou 496 Next larger element I
- NFT:使用 EIP-2981 開啟 NFT 版稅之旅
- [TA frost wolf \u may- hundred talents plan] 1.2.3 MVP matrix operation
- [JPCs publication] the Third International Conference on control theory and application in 2022 (icocta 2022)
- Access denied for user ‘ODBC‘@‘localhost‘ (using password: NO)
猜你喜欢

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

HoloLens2开发环境搭建及部署app

Use selenium automated test tool to climb the enrollment score line and ranking of colleges and universities related to the college entrance examination
![[leetcode skimming] February summary (updating)](/img/62/0d0d9f11434e49d33754a2e4f2ea65.jpg)
[leetcode skimming] February summary (updating)

DO280管理应用部署--RC

Jenkins automatically cleans up construction history

盘点华为云GaussDB(for Redis)六大秒级能力

JMeter学习笔记2-图形界面简单介绍

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

【人话版】WEB3黑暗森林中的隐私博弈
随机推荐
JMeter login failure, extracting login token, and obtaining token problem solving
嵌入式系統開發筆記80:應用Qt Designer進行主界面設計
[human version] Web3 privacy game in the dark forest
283.移动零
How to ensure the idempotency of the high concurrency interface?
Edge浏览器的小技巧:Enter+Ctrl可以自动将地址栏转换为网址
[EI search] important information conference of the 6th International Conference on materials engineering and advanced manufacturing technology (meamt 2022) in 2022 website: www.meamt Org meeting time
Deep learning | rnn/lstm of naturallanguageprocessing
采购数智化爆发在即,支出宝'3+2'体系助力企业打造核心竞争优势
Why can't you find the corresponding function by clicking go to definiton (super easy has a diagram)
高并发下接口幂等性如何保证?
Recommend the best product development process in the Internet industry!
Use selenium automated test tool to climb the enrollment score line and ranking of colleges and universities related to the college entrance examination
The problem of integrating Alibaba cloud SMS: non static methods cannot be referenced from the static context
Loop filtering based on Unet
小程序中自定义组件
[untitled] Li Kou 496 Next larger element I
京东智能客服言犀意图体系搭建和意图识别技术介绍
Volley parsing data shows networking failure
206.反转链表