Wilhel

Wilhel

Weekly Report #May - Week 19, 2023

Preface#

This article is a record and reflection on the life from 2023-05-08 to 2023-05-14.

Life#

  • The new round of team check-in for not forgetting words has started, continue to learn vocabulary.
  • A very capable colleague who has been with the company for a long time has been optimized and has officially started. Let's see how long I can last.
  • This week's recipe
    • Breakfast
      • Oatmeal yogurt cup

        Layer yogurt and oats, make it in advance and refrigerate it overnight in a sealed container in the refrigerator. Bring it to the company to eat directly the next morning. Convenient and delicious.

      • Bagel + cheese

        Cut the bagel in half and freeze it in a sealed bag. Air fry at 180 degrees for 5 minutes, spread cheese on it, and you can add a fried egg.

      • Pan-fried chicken cutlet + fried egg

        Marinate the chicken leg cutlet in Orleans marinade in advance, cover it with plastic wrap and refrigerate it. Fry it with butter until the surface is cooked on both sides, then add water and cover the pot to simmer for a few minutes.

  • Modify xLog global font settings
    @import url("https://cdnjs.cloudflare.com/ajax/libs/lxgw-wenkai-screen-webfont/1.7.0/lxgwwenkaiscreenr.css");
    
    :root {
    	--font-fans: "LXGW WenKai Screen R";
    }
    
  • Accidentally spilled powder on the grinding disc of the coffee grinder, and broke the adjustment rod when disassembling the grinding disc. Feeling upset...

Study#

English#

Difference between "Attend" and "Attempt"#

  1. "Attend" means "to take care of, look after" and also has the meaning of "to be present". When it means "to try" to complete something, it emphasizes the attitude of attention and effort towards the matter.
  2. "Attempt" means "to try, to attempt" and represents the action taken to achieve a goal or complete something. It emphasizes the actual action and effort taken.
  3. In summary:
    • "Attend" emphasizes the proactive attitude towards something.
    • "Attempt" emphasizes the actual action and effort taken.
    • "Attend" is more static, while "Attempt" is more dynamic.
    • In some cases, the two can be interchangeable, but "Attend" focuses on mindset, while "Attempt" focuses on behavior.

"Hit the ground running"#

This is a fixed phrase meaning "to start taking action immediately".

It means to start taking action quickly after entering a new environment (such as a new job or project) without delay or postponement. It represents a proactive and fast-paced mindset.

"Fall prey to sth"#

It usually describes a situation where one party is invaded, exploited, or influenced by a more powerful party due to being comparatively weak or inattentive.

"Wishful thinking"#

It means a wishful or overly optimistic way of thinking, referring to an unrealistic or overly optimistic mindset.

"Multiplication table"#

The table of multiplication.

"Stay put"#

It means to stay in the original position and not leave or move to another place. It indicates staying still or not taking action. It can be used to advise or inform someone to stay in their current position and not leave or go to another location temporarily.

This is often done for safety reasons, to prevent confusion or while waiting for further instructions. It can also be used to indicate that one cannot leave the current position due to various reasons such as work requirements.

Technology#

MySQL#

Index#

There was a data issue that required modifying the database. When using the select statement, 36 rows of data were retrieved, but when using the update statement with the same conditions, it affected over 1 million rows of data in the entire table. After contacting the DBA and adding an index, the update statement executed normally.

UPDATE `database`.`table` SET  `column_a` = 'name' WHERE  `column_b` = 'message'  AND `column_a` = 'default'

-- Add index
-- idx_a_b	`column_a`, `column_b`	NORMAL	BTREE
Reason

https://xiaolincoding.com/mysql/lock/update_index.html

The default transaction isolation level of the InnoDB storage engine is "repeatable read". However, under this isolation level, when multiple transactions are concurrent, phantom reads may occur. Phantom reads refer to the phenomenon that when the same query is executed twice in the same transaction, the second query may return rows that did not exist before.

Therefore, the InnoDB storage engine implements row locks itself, using next-key locks (a combination of record locks and gap locks) to lock the records themselves and the "gaps" between records, preventing other transactions from inserting new records between them, thus avoiding the phenomenon of phantom reads.

When executing an update statement, it actually acquires an exclusive lock (X lock) on the record. If another transaction tries to modify the record that holds the exclusive lock, it will be blocked. Additionally, this lock is not released immediately after executing the update statement, but is released when the transaction ends.

If the where condition of the update statement does not use an index, a full table scan will be performed, resulting in next-key locks (record locks + gap locks) being applied to all records.

Summary

The update statement must meet one of the following conditions to be executed successfully:

  • Use where and the where condition must include indexed columns.
  • Use limit.
  • Use both where and limit, in which case the where condition does not need to include indexed columns.

The delete statement must meet one of the following conditions to be executed successfully:

  • Use where and the where condition must include indexed columns.
  • Use both where and limit, in which case the where condition does not need to include indexed columns.

If the where condition includes indexed columns, but the optimizer chooses to scan the entire table instead of using the index, we can use force index([index_name]) to tell the optimizer which index to use, thus avoiding the potential risk of locking the entire table.

Favorites#

  • tldr Simplified and community-driven man pages.
  • Vim Adventures A game to learn how to use Vim online.
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.