A DB2 Performance Tuning Roadmap --DIVE INTO LOCK
在整理了DB2 LOG相关内容的基础之上,这章整理lock的内容,相比较与log,lock的内容更多的与应用相关,涉及内容方方面面更加复杂。DBMS在本质上不同于文件系统的地方在于DBMS系统所支持的事务。 如果log的引入是为了保证持久化,那么LOCK的引入就是保证事务串行化,解决事务的并发带来了资源的RACE CONDITION。不同的事务场景,定义了不同的并发需求,为此定义了4种事务的隔离级别,不同的DBMS引入了不同的锁机制来实现。DB2的串行化机制主要是通过LOCK,LATCH,CLAIM/DRAIM 来实现,具体的LOCK的相关属性以及LOCK属性对应用程序的影响比如OBJECT,SIZE,MODE,DURATION,PARTICIPANTS,PARAMETER LOCATIONS都进行了介绍。当引入了DBMS CLUSTER(DB2中为DATA SHARING GROUP,而ORACLE中为ORACEL RAC) 以后,为了处理不同不同MEMBER之间数据的一致性,DB2引入了PHYSICAL LOCK以及CF LOCK STRTURE 来实现全局LOCK 冲突检测。单个SUBSYSTEM中,主要的冲突有TIMEOUT,DEADLOCK,在DATASHARING GROUP,引入了新的CONTENTION,XES CONTENTION,FALSE CONTENTION,GLOBAL LOCK CONTENTION。引入LOCK的同时不可避免的带来了新的OVERHEAD,DB2主要通过IRLM,XES,CF等处理锁资源的请求,除了地址空间除了锁请求之外,由于应用本身设计不合理或是某些特定的场景带来了很多问题,如TEMEOUT,DEADLOCK,LOCK ESCALATION等,如何有效的避免这些问题,需要系统运维人员以及开发人员共同努力。
本文的行文脉络基于个人对DBMS LOCK的认知层次,行文的逻辑性,合理性,整理内容的知识面的广度和深度都有待进一步的思考。
这篇博客从落笔到完成大体的框架,持持续续时间已经接近2周,应该是自己耗时最长的一篇博客,纵使如此,每一次查看,发下仍有新的东西需要自己补充,等后续会继续补充自己的理解。
- LOCK OVERVIEW
- WHY LOCKS ? DB2 Serialization Mechanisms
- Data Consistency And Database Concurrency
- Phenomena Seen When Transactions Run Concurrently
- Lost Updates
- DIRTY READS
- Non-Repeatable Reads
- Phantoms
- Data Consistency And Database Concurrency
- LOCK PROPERTIES
- LOCK OBJECT OWNER
- LOCK PARTICIPANTS
- LOCK SIZE
- LOCK MODE
- LOCK DURATION
- LOCK REQUEST AND RELEASE
- LOCK AND TRAN ISOLATION LELVEL
- LOCKING PARAMETERS LOCATIONS
- DDL
- DML
- Precompiler Locking Parameters
- Bind Locking Parameters
- Zparm Locking Parameters
- CLAIM AND DRAIN
- LATCH
- ADVANCED TOPICS
- L-LOCK(EXPLICIT HIERARCHICAL LOCKING )EHL
- PHYSICAL LOCK
- RETAINED LOCKS(UPDATE LOCKS)
- IMPACT OF Retained LOCKS
- LOCK SCOPE:
- LOCAL LOCK
- GLOBAL LOCK
- GLOBAL LOCK COMMUNICATION
- Page Set P-Lock Negotiation
- CF LOCK STRUCTURE
- MODIFIED RESOURCE LIST(MRL)
- LOCK TABLE
- XCF
- XES
- XES CONTENTION
- FALSE CONTENTION
- GLOBAL CONTENTION
- DATA SHARING ACTIVITY REPORT
- Lock Structure Shortage Actions
- Types of locking problems
- How do I find out I have a problem
- Analyzing concurrency problems --TOOLBOXS
- DB2 commands and EXPLAIN
- DB2 TRACES
- EXAMPLE:Analysis of a simple deadlock scenario and solution
- DBD is locked
- WHY LOCKS ? DB2 Serialization Mechanisms
LOCK OVERVIEW
WHY LOCKS ?DB2 Serialization Mechanisms
Data Consistency And Database Concurrency
DBMS区别与文件系统的最本质区别:DBMS支持事务
DBMS :Allowing multiple users to access a database simultaneously without compromising data integrity.
A transaction (or unit of work)is a recoverable sequence of one or more SQL operations that are grouped together as a single unit, usually within an application process.
One of the mechanisms DB2 uses to keep data consistent is the transaction. A transaction or(otherwise known as a unit of work) is a recoverable sequence of one or more SQL operations that are grouped together as a single unit, usually within an application process. The initiation and termination of a single transaction defines points of data consistency within a database; either the effects of all SQL operations performed within a transaction are applied to the database and made permanent (committed), or the effects of all SQL operations performed are completely "undone" and thrown away (rolled back).
Phenomena Seen When Transactions Run Concurrently
事务并发带来的问题,为了解决这些问题,DB2定义了4种事务隔离级别。
- LOST UPDATE
- DIRTY READS
- NON-REPEATABLE READS
- PHANTOMS
Lost Updates
Occurs when two transactions read the same data, both attempt to update the data read, and one of the updates is lost
Transaction 1 and Transaction 2 read the same row of data and both calculate new values for that row based upon the original values read. If Transaction 1 updates the row with its new value and Transaction 2 then updates the same row, the update operation performed by Transaction 1 is lost
DIRTY READS
Occurs when a transaction reads data that has not yet been committed
Transaction 1 changes a row of data and Transaction 2 reads the changed row before Transaction 1 commits the change. If Transaction 1 rolls back the change, Transaction 2 will have read data that theoretically, never existed.
Non-Repeatable Reads
Occurs when a transaction executes the same query multiple times and gets different results with each execution
Transaction 1 reads a row of data, then Transaction 2 modifies or deletes that row and commits the change. When Transaction 1 attempts to reread the row, it will retrieve different data values
Phantoms
Occurs when a row of data that matches some search criteria is not seen initially
Transaction 1 retrieves a set of rows that satisfy some search criteria, then Transaction 2 inserts a new row that contains matching search criteria for Transaction 1’s query. If Transaction 1 re-executes the query that produced the original set of rows, a different set of rows will be retrieved – the new row added by Transaction 2 will now be included in the set of rows returned
LOCK PROPERTIES
LOCK OBJECT OWNER
这里的object是指锁所施加的对象,不同的锁所能适用的对象是不同的。如PAGE LOCK的对象肯定是PAGE.
OWNER 表示谁持有锁,有的是TRAN,有的是DB2 MEMBER
LOCK PARTICIPANTS
Locking is a complex interaction of many parts.
- DBM1, where SQL executes, is the beginning of locking.
- The IRLM, a separate address space, is where locks are held and managed. The DBM1 AS requests locks from the IRLM. In addition to its functionality of granting and releasing locks, the IRLM is also in charge of detecting deadlock and timeout situations.
- In a data sharing environment, there are two other ingredients in the soup. The XCF address space is where its XCF component resides. The XES does some lock management and communicates directly with the lock structure in the coupling facility
LOCK SIZE
访问数据的范围
设计锁的颗粒度对系统和应用均有影响:设计时要综合考虑- 锁本身也是一种资源,持有的lock size越大,锁资源消耗越小
- lock size的大小与对应用访问的并发(concurrent)成反比关系
- LOCK SIZE 带来的另外一个副作用就是当你申请的锁资源足够多,以至于超过系统设定的阀值时(NUMLKUS/NUMLKTS/LOCK MAX =0,SYSTEM,N),
lock size: PAGE/ROW /TABLE /PARENT LOCKS:TABLESPACE /PARTITIONPage/Row locks are not compatible with tablespace locks The solution is "Intent Locking" Regardless of the locksize, DB2 will always start with a tablespace lock
INTENT LOCKS:IS/IX USED whenever page or row locks are being used
GROSS LOCKS:The gross locks (S, U, SIX and X) are tablespace locks which are used in three
situations - lock size tablespace
- lock table for a non-segmented tablespace
- lock escalation for a non-partitioned tablespace
LOCK MODE
数据的访问方式:独占还是共享 S/U/X
X:exclusive, not sharable with other
S:shared, sharable with other S-locks
LOCK MODE之间的兼容性如下:S U X S Y Y N U Y N N X N N N LOCK DURATION
持有数据的时间:commit,across commit(with hold)
FROM:START OF FIRST USE
TO :COMMIT OR MOMENTIALIY
LOCK REQUEST AND RELEASE
When modifying data (Insert, Update and Delete),DB2 determines all locking actions
- Lock size Tablespace
=> lock is taken at first use
=> lock is released at commit or deallocate - SQL- Statement “Lock Table … in Exclusive Mode”
=> initially an IX-lock (on the tablespace)
=> lock is taken at first use
=> lock is released at commit or deallocate - Page lock and row lock
=> initially an IX-lock (on the tablespace)
=> then X-locks are taken on each page/row as needed
=> these X-locks are released at commit
LOCK AND TRAN ISOLATION LELVEL
每一种事务隔离级别锁所能解决的问题
- Repeatable Read
=> locks all data read by DB2
=> guarantees that exact the same result set will be returned when reusing the cursor - Read Stability
=> locks all data “seen” by the application
=> guarantees that at least the same result set will be returned when reusing the cursor - Uncommitted Read (UR)
Pro:
Our read will be “cheaper”
We are not disturbing others
Con:
We may read data
which may be “un-inserted”
which may be “un-updated”
When you are reading live (operational) data,you can never guarantee exact results - Cursor Stability (CS)
=> a lock is taken when the row is fetched
=> the lock is released when next row is fetched,
or at end of data or at Close Cursor
For page locks:
=> a lock is taken when the first row on the page is fetched
=> the lock is released when next page is fetched,
or at end of data or at Close Cursor
This means:When you have fetched a row and have not reached end of data or closed the cursor,
you are holding an S-lock on the row or page - LOCK AVOIDANCE
UpdateableDECLARE upd_cur CURSOR FOR SELECT data1, data2 FROM table FOR UPDATE OF colx
Read-OnlyDECLARE ro_cur CURSOR FOR SELECT DEPTNO, AVG(SALARY) FROM EMP GROUP BY DEPTNO
AmbiguousDECLARE amb_cur CURSOR FOR SELECT data1, data2 FROM table
=> Use FOR READ ONLY or FOR FETCH ONLY
If we have the following:
Read-Only (or Ambiguous) Cursor
Cursor Stability
Currentdata No
it is possible that we can get "Lock Avoidance“
Lock avoidance is advantageous!
A possible problem with Currentdata No:
Fetch a row
...
Update (or Delete) Where Key = :hostkey
can give SQLSTATE="02000" (Not Found)
LOCKING PARAMETERS LOCATIONS
下面分别介绍了系统参数,应用参数如何影响LOCK行为
DDL
OBJECT DEFINITION,CREATE TABLESPACE:
- LOCKMAX (INTEGER,SYSTEM)
- LOCKSIZE
DEFAULT:ANY
OPTION:ANY,TABLESPACE,TABLE,PAGE,ROW,LOB - MAXROW: INTEGER
DEFAULT:255
USED TO increase concurrency
MAXROWS 1Used to emulate row-level locking
locking without the costs of page p-lock processing - MEMBERCLUSTER:(P-LOCK)
Clustering per member
Reduce p-lock contentions forspace mappages
Destroys clustering according to clustering index - TRACKMOD (P-LOCK)
DEFAUTL:NO
OPTION:YES/NO
DML
- LOCK TABLE
SYNTAX:LOCK {TABLE, TABLESPACE [partno]} IN
{EXCLUSIVE, SHARE} MODE - Cursor Definitions
FOR UPDATE OF
FOR READ ONLY- Tells DB2 the result set is read-only
- Positioned UPDATEs and DELETEs are not allowed
- No U or X locks will be obtained for the cursor
- Isolation Clause
WITH [UR, CS, RS, RR]- USE AND KEEP EXCLUSIVE LOCKS
- USE AND KEEP UPDATE LOCKS
- USE AND KEEP SHARE LOCKS
Precompiler Locking Parameters
NOFOR Option:NO FOR update clause mandatory for positioned updates
STDSQL(YES): Implies NOFOR
Bind Locking Parameters
- CURRENTDATA
FUNCTION:CURRENTDATA helps to determine if DB2 will attempt to avoid locks
mean:Must the data in program be equal to the data at the current cursor position
lock aovidance
demo:
CURRENTDATA(NO)
note - ISOLATION
- RELEASE
Zparm Locking Parameters
ZPARM | MEANING |
---|---|
URCHKTH | UR Checkpoint Frequency Threshold |
URLGWTH | UR Log Write Threshold |
LRDRTHLD | Long-Running Reader |
RELCURHL | Release Held Lock |
EVALUNC | Evaluate Uncommitted |
SKIPUNCI | Skip Uncommitted Inserts |
RRULOCK | U lock for RR/RS |
XLKUPDLT | X lock for searched U/D |
NUMLKTS | Locks per Table(space) |
NUMLKUS | Locks per User |
CLAIM AND DRAIN
BETWEEN SQL AND SQL:DB2 USE LOCKS
BETWEEN UTILITY AND SQL:DB2 USE CLAIM AND DRAIN
BASE:
FOR EACH OBJECT(TABLESPACE,PARTITION,TABLE,IDNEXSPACE),THERE IS A CLAIM-COUNT
WHICH IS INCREASED 1 AT START AND DECREASE BY 1 AT COMMIT
A utility starts with a Drain
No new Claims are allowed (wait, maybe timeout)
If the Claim-count >0 the utility waits (maybe timeout)
When the Claim-count reaches zero, the utility can continue
Two important situations:
- UR (Uncommitted Read) takes no locks – but increases Claim-count (UR REQUEST MASS-DELETE LOCKS)
- For Cursor With Hold the Claim-count is not reduced at Commit
A claim is a notification to DB2 that a particular object is currently being accessed. Claims usually do not continue to exist beyond the commit point one exception being a Cursor with Hold. In order to access the DB2 object within the next unit of work, an application needs to make a new claim.Claims notify DB2 that there is current interest in or activity on a DB2 object.Even if Uncommitted Read doesn’t take any locks, a claim is taken. As long as there are any claims on a DB2 object, no drains may be taken on the object until those claims are released.
A drain is the action of obtaining access to a DB2 object, by:Preventing any new claims against the object.Waiting for all existing claims on the object to be released.
A drain on a DB2 object causes DB2 to quiesce all applications currently claiming that resource, by allowing them to reach a commit point but preventing them (or any other application process) from making a new claim.A drain lock also prevents conflicting processes from trying to drain the same object at the same time.
Utilities detect claimers are present and wait
Drain Write waits for all write claims to be released
Drain All waits for claims on all classes to be released
SHRLEVEL(CHANGE) Utilities are CLAIMers
LATCH
Latches – managed by DB2
? BM page latching for index and data pages
? DB2 internal latching (many latches grouped into 32 latch classes)
? Latches – managed by IRLM
? Internal IRLM serialization
ADVANCED TOPICS
虽然标题是advanced topics,其实涉及的内容并没有本质的区别,只不过我们在看待问题,分析问题时需要从单个DB2 SUBSYSTEM的视角上升到DBMS CLUSTER的高度,即DATA SHARING GROUP的高度。为了处理不同的member之间共享数据的COHERENCY问题,DB2引入P-LOCK,区别主要在于单个DB2 SUBSYSTEM中的LOCK owner均为tran,而P-LOCK的owner为DB2 SUBSYSTEM.因此这里的内容按照这种分类进行介绍L-LOCK,P-LOCK,RETAINED LOCK,这几种锁之间的区别需要了解。
L-LOCK(EXPLICIT HIERARCHICAL LOCKING )EHL
特点:
THE KIND YOU HAVE IN BOTH DATA SHARING AND NON DATA SHARING SUBSYTEM THEN CONTROL DATA CONCRRRENCY OF ACCESS TO OBJECTS THEN CAN BE LOCAL OR GLOBAL THEY ASSOTIATED WITH PROGRAMS
WHY IS HIERACHICAL
SO THE MEMBER DB2 SUBSYSTEM WILL NOT PROPAGATE L-LOCKS TO THE CF UNNECESSARILY
- PARENT LOCK
PARENT LOCK ARE TABLE SPACE LOCKS OR DATA PARTITION LOCK
GROSS LOCKS ARE ALWAYS GLOBAL LOCKS - CHILD LOCK
PAGE /ROW LOCK
EXCEPTION: MAYBE TABLES LOCKS IF SEGMENT TABLESPACE
PAGE/ROW LOCK CAN BE GRANTED LOCALLY IF NOT IN INTER-DB2 R/W SHARING STATE
ASYNCHRONOUS CHILD PROPAGATION WHEN INTER-SYTEM INTEREST FIST OCCUR - L-LOCK PROPAGATION
NOT ALL L-LOCKS ARE PROPAGATED TO THE DB2 LOCK STRUCTURE
PARENT L-LOCKS ARE ALMOST ALWAYS PROPAGATE TO THE DB2 LOCK STRUCTURE - Child Locks Propagation based on Pageset P-lock
Now based on cached(held) state of the pageset P-lock
If pageset P-lock negotiated from X to SIX or IX, then child L-locks propagated
Reduced volatility
If P-lock not held at time of child L-lock request, child lock will be propagated
"Index-only" scan (if any locks taken) must open table space
Parent L-lock no longer need to be held in cached state after DB2 failure
A pageset IX L-lock no longer held as a retained X lock
Important availability benefit in data sharing
CHILD L-LOCKS ARE PROPAGATED TO THE DB2 LOCK STRUCTURE ONLY IF THERE IS INTER DB2 PARENT L-LOCKS CONFICT ON A DATABASES OBJECT
PHYSICAL LOCK
特点:
EXCLUSIVE TO DATA SHARING
ARE ONLY GLOBAL
USED TO MAINTAIN DATA COHERENCY IN DATA SHARING
ALSO USED TO MAINTAIN EDMPOOL CONSISTENCY AMONG MEMBERS
ASSOTIATED BY(OWNED BY) DB2 MEMBERS
P-LOCK CAN BE NEGOTIATTED BETWEEN DB2 MEMBERS
NO TIMEOUT OR DEADLOCK DETECTION
分类
- PAGE SET P-LOCK
- PAGE P-LOCK
- PAGE SET/PARTITION CASTOUT P-LOCK
- GBP STRUCTURE P-LOCK
RETAINED LOCKS(UPDATE LOCKS)
AIM:PROTECT UNCOMMITED DATA FROM ACCESS BY THER LOCK STRUCTURE
UPDATE(IX,SIX,X)
GLOBAL LOCKS ARE RETAINED AFTER FAILTUREIMPACT OF Retained LOCKS
<img src="/static/imghwm/default1.png" data-src="http://www.bkjia.com/uploads/allimg/160227/11433Q233-1.png" class="lazy" style="max-width:90%" style="max-width:90%" alt="">The ONLY way to clear retained locks is by estarting the failed DB2 subsystem.
LOCK SCOPE:
LOCAL LOCK
GLOBAL LOCK
A LOCK THAT A DB2 SHARING DB2 MEMBERHAS TOMAKE KNOWN TO OTHERS MEMBERS OF THIS DATA SHARING GROUP
THE IRLM VIA XES,PROPAGATE TO THES LOCKS TO THE STRUCTURE IN THE CF
XCF,XES的内容在XES contention部分介绍。
GLOBAL LOCK COMMUNICATION
HOW ARE GLOBAL LOCK REQUESTS MADE KNOWN TO OTHER DB2 MEMBERS?
THEY ARE PROPAGATED TO DB2 LOCK STRUCTUREPage Set P-Lock Negotiation

与APPLICATION LOCK不同的是,PHYSCIAL LOCK 可以做Page Set P-Lock Negotiation。
上图展示了INERDB2 READ/WRITE INTEREST场景下的PAGE SET P-LOCK NEGOTIATION。所谓的negotiation就是锁请求方以及锁申请方将锁请求均DOWNGRADE,从而达到compatible的目的。需要注意的是,PAGE SET P-LOCK STATE状态的变化需要涉及IRLM以及XCF通讯机制。PAGE SET P-LOCK对GLOBAL BUFFER POOL起一种标志作用,
对于READ的DB2 SUBSYSTEM, must register its
interest in read pages in the GBP directory
对于UPDATER的DB2 SUBSYSTEM,must write updated pages to the group buffer pool and register those updated pages in the GBP directory
CF LOCK STRUCTURE
DEVIDE INTO TWO PARTS OF CF LOCK STRUCTURE RATIO OF LAST TWO COMPONETS DEFAULT ROUGHLY 50%CAN BE ALTERED BY IRLM PARAMETER
MODIFIED RESOURCE LIST(MRL)
OVERVIEW OF MRL STRUCTURE
ACTIVEstatus of active means that the DB2 system is running.
Retained, on the other hand, means that a DB2 and/or its associated IRLM has failed
CONTAINS ENTRIES FOR ALL CRURENTLY HELD MODIFY LOCKS
IN THE EVENT OF DB2 FAILTURE ENSURE THAT OTHER MEMBER OF DB2 KNOW WHICH LOCKS MUST BERETIANED
It is essentially a list structure that lists all the update or modify locks in the data sharing group
DISPLAY GROUP ; Display “LIST ENTRIES IN USE”
NUMBER LIST ENTRIES : 7353, LIST ENTRIES IN USE: 1834
WARNING: When the LIST ENTRIES IN USE catches up to the NUMBER LIST ENTRIES, new modify lock requests will not be granted, and transactions will begin to fail with -904s.
LOCK TABLE
A 'POOL' OF HASH POINTERS
CONTAINS ENTRIES FOR ALL READ AND MODIFY LOCKS
USED FOR GLOBAL LOCK CONTENTION
It is very difficult to keep track of how full a randomly populated table is, so the only way to track its utilization is indirectly. In DB2 data sharing, that tracking mechanism is false contention
SIZE OF EACH INDIVIDUAL ENTRY SET BY MAXUSRS PARAMETER IN IRLMPROC OF FIRST IRLM JOIN THE GROUP
NUMBER OF MEMBER IN THE GROUP
XCF
其实主要的目的就是提供INTER-SUBSYTEM之间通讯的API,主要的功能有三个:
- Signaling Services provide a method for communicating between members of the same XCF roup, which is a set of related members defined to XCF by a multisystem application. This function supports the single system image concept of a parallel sysplex, both by providing communication etween subsystems, such as DB2 members, as well as z/OS components in each image.
- Group Services allow multisystem applications to define groups and their members to XCF. Group services also provide the means for requesting information about the other members in the same XCF group, using SETXCF commands.
- Status Monitoring Services of XCF provide the means for monitoring the status of other z/OS systems in the same sysplex.
XES
提供了不同的SUBSYSTEM访问CF的API。XES本身仅支持两种锁类型,即S|X类型。但是DB2 SUBSYTEMB本身支持多种不同类型的锁,这就带来一个问题,这些锁类型在上送到CF时,应该如何映射,DB2 V7 Protocol Level 1和V8 Protocol Level 2的处理差别比较大,当然这种变化的目的还是在保证能完全检测到锁冲突的前提下,减少上送到CF锁的请求次数,优化全局锁检测机制。V7到V8优化的出发点还是进一步的解决XES锁映射问题,V8到V10甚至V11基本上无变化,可见V8优化的意义之重大。
DB2在DATA SHARING 下是显式的三级锁结构,TWO LEVELS OF APPLICATION LOCKS外加DB2 member级别的PAGE SET P LOCK.
DB2 PAGE SET P-LOCK的状态变化如下图:action DB2 member interest page set p lock STAE CHANGE open PP-LOCK S/IS NONE->R/O PSEUDO OPEN PP-LOCK IX/SIX/X/U R/O->R/W PSEDUO CLOSE PP-LOCK S/IS R/W->R/O Physical CLOSE NONE R/O->NONE
产生的根源为XES本身设计时仅支持两种锁类型,
?XES Contention = XES-level resource contention as XES
only understands S or X
eg member 1 asking for IX and member 2 for IS
Big relief in V8
产生的根源主要是由于DB2 lock table定义的太小或是hash算法离散型不够好,导致不同的DB2资源hash到同一lock table hash class上而产生的冲突,可以通过放大CF lock table来解决,因此FALSE CONTENTION标志着 CF LOCK STRUCTURE的大小是否合适。
GLOBAL CONTENTIONGLOBAL CONTENTION 本身包含XES CONTENTION,FALSE CONTENTION,REAL CONTENTION,其中REAL CONTENTION 确实为资源冲突,如资源热点,其它的两种冲突是由于引入DATA SHARING 的OVERHEAD
根据上面的介绍,下面给出A DB2 Performance Tuning Roadmap-2data sharing BLOCK的一个展示
L-LOCK(SHARING)部分表明了数据共享的程度
P/L XES CONTENTION表明P-LOCK,L-LOCK中需要上送CF的比例。其

PHP와 Python은 각각 고유 한 장점이 있으며 선택은 프로젝트 요구 사항을 기반으로해야합니다. 1.PHP는 간단한 구문과 높은 실행 효율로 웹 개발에 적합합니다. 2. Python은 간결한 구문 및 풍부한 라이브러리를 갖춘 데이터 과학 및 기계 학습에 적합합니다.

PHP는 죽지 않고 끊임없이 적응하고 진화합니다. 1) PHP는 1994 년부터 새로운 기술 트렌드에 적응하기 위해 여러 버전 반복을 겪었습니다. 2) 현재 전자 상거래, 컨텐츠 관리 시스템 및 기타 분야에서 널리 사용됩니다. 3) PHP8은 성능과 현대화를 개선하기 위해 JIT 컴파일러 및 기타 기능을 소개합니다. 4) Opcache를 사용하고 PSR-12 표준을 따라 성능 및 코드 품질을 최적화하십시오.

PHP의 미래는 새로운 기술 트렌드에 적응하고 혁신적인 기능을 도입함으로써 달성 될 것입니다. 1) 클라우드 컴퓨팅, 컨테이너화 및 마이크로 서비스 아키텍처에 적응, Docker 및 Kubernetes 지원; 2) 성능 및 데이터 처리 효율을 향상시키기 위해 JIT 컴파일러 및 열거 유형을 도입합니다. 3) 지속적으로 성능을 최적화하고 모범 사례를 홍보합니다.

PHP에서, 특성은 방법 재사용이 필요하지만 상속에 적합하지 않은 상황에 적합합니다. 1) 특성은 클래스에서 다중 상속의 복잡성을 피할 수 있도록 수많은 방법을 허용합니다. 2) 특성을 사용할 때는 대안과 키워드를 통해 해결할 수있는 방법 충돌에주의를 기울여야합니다. 3) 성능을 최적화하고 코드 유지 보수성을 향상시키기 위해 특성을 과도하게 사용해야하며 단일 책임을 유지해야합니다.

의존성 주입 컨테이너 (DIC)는 PHP 프로젝트에 사용하기위한 객체 종속성을 관리하고 제공하는 도구입니다. DIC의 주요 이점에는 다음이 포함됩니다. 1. 디커플링, 구성 요소 독립적 인 코드는 유지 관리 및 테스트가 쉽습니다. 2. 유연성, 의존성을 교체 또는 수정하기 쉽습니다. 3. 테스트 가능성, 단위 테스트를 위해 모의 객체를 주입하기에 편리합니다.

SplfixedArray는 PHP의 고정 크기 배열로, 고성능 및 메모리 사용이 필요한 시나리오에 적합합니다. 1) 동적 조정으로 인한 오버 헤드를 피하기 위해 생성 할 때 크기를 지정해야합니다. 2) C 언어 배열을 기반으로 메모리 및 빠른 액세스 속도를 직접 작동합니다. 3) 대규모 데이터 처리 및 메모리에 민감한 환경에 적합하지만 크기가 고정되어 있으므로주의해서 사용해야합니다.

PHP는 $ \ _ 파일 변수를 통해 파일 업로드를 처리합니다. 보안을 보장하는 방법에는 다음이 포함됩니다. 1. 오류 확인 확인, 2. 파일 유형 및 크기 확인, 3 파일 덮어 쓰기 방지, 4. 파일을 영구 저장소 위치로 이동하십시오.

JavaScript에서는 NullCoalescingOperator (??) 및 NullCoalescingAssignmentOperator (?? =)를 사용할 수 있습니다. 1. 2. ??= 변수를 오른쪽 피연산자의 값에 할당하지만 변수가 무효 또는 정의되지 않은 경우에만. 이 연산자는 코드 로직을 단순화하고 가독성과 성능을 향상시킵니다.


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

에디트플러스 중국어 크랙 버전
작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

SublimeText3 Linux 새 버전
SublimeText3 Linux 최신 버전

WebStorm Mac 버전
유용한 JavaScript 개발 도구

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

Atom Editor Mac 버전 다운로드
가장 인기 있는 오픈 소스 편집기
