测试环境模拟: SQL drop table t_col_type purge; create table t_col_type(id varchar2(20),col2 varchar2(20),col3 varchar2(20)); insert into t_col_type select rownum,abc,efg from dual connect by level=10000; commit; create index idx_id on t_c
测试环境模拟:
SQL> drop table t_col_type purge;
create table t_col_type(id varchar2(20),col2 varchar2(20),col3 varchar2(20));
insert into t_col_type select rownum,'abc','efg' from dual connect by level
commit;
create index idx_id on t_col_type(id);
set linesize 1000
set autotrace traceonlydrop table t_col_type purge
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> select * from t_col_type where id=6;
Execution Plan
----------------------------------------------------------
Plan hash value: 3191204463
--------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 36 | 8 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL | T_COL_TYPE | 1 | 36 | 8 (0)| 00:00:01 |
--------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(TO_NUMBER("ID")=6)
Note
-----
- dynamic sampling used for this statement
Statistics
----------------------------------------------------------
5 recursive calls
0 db block gets
64 consistent gets
0 physical reads
0 redo size
640 bytes sent via SQL*Net to client
469 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
这里好像有点奇怪啊,明明建了index [create index idx_id on t_col_type(id);]但是为啥没有用到呢?
---查看表上列是否有索引
SQL> select index_name , table_name,column_name from all_ind_columns where table_name ='T_COL_TYPE';
INDEX_NAME
------------------------------------------------------------
TABLE_NAME
------------------------------------------------------------
COLUMN_NAME
--------------------------------------------------------------------------------
IDX_ID
T_COL_TYPE
ID
----查看表结构
SQL> desc scott.T_COL_TYPE
Name Null? Type
----------------------------------------- -------- ----------------------------
ID VARCHAR2(20)----------注意这里的字符类型
COL2 VARCHAR2(20)
COL3 VARCHAR2(20)
再次关注下 执行计划中的谓语信息:
1 - filter(TO_NUMBER("ID")=6) ----------这里发生了类型转换
所以在执行计划中就无法用已有的索引,那么如何才能让他正确走索引呢?
select * from t_col_type where id='6';------注意下这里的区别加了单引号,表明这是个字符,
Execution Plan
----------------------------------------------------------
Plan hash value: 3998173245
------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 36 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID | T_COL_TYPE | 1 | 36 | 2 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | IDX_ID | 1 | | 1 (0)| 00:00:01 |
------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("ID"='6')
Note
-----
- dynamic sampling used for this statement
Statistics
----------------------------------------------------------
9 recursive calls
0 db block gets
39 consistent gets
1 physical reads
0 redo size
640 bytes sent via SQL*Net to client
469 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed

mysqlhandlesconcurrencyusingamixofrow-reveltable-levellocking, 주로 throughinnodb'srow-levellocking.comparedtootherrdbms, mysql 's trofficefice formanyusecasesbutmayfacechallengeswithdeadlocksandlacksadvancturespostpostgresql'sserializa

mysqlhandlestransactionseffectialthicatied theinnodbengine, support-propertiessimilartopostgresqlandoracle.1) mysqlusesepeatablereadasthedefaultisolationlevel, itpoptormizestperformance와 함께

mysqlisbetterforspeedandsimplicity, 적절한 위장; postgresqlexcelsincmoMplexDatascenarioswithrobustFeat.MySqlisIdeAlforQuickProjectSandread-Heavytasks, whilepostgresqlisprefferredforapticationstrictaintetaintegritytetegritytetetaintetaintetaintegritytetaintegritytetaintegritytetainte

MySQL은 비동기식, 반 동시성 및 그룹 복제의 세 가지 모드를 통해 데이터 복제를 처리합니다. 1) 비동기 복제 성능은 높지만 데이터가 손실 될 수 있습니다. 2) 반 동기화 복제는 데이터 보안을 향상 시키지만 대기 시간을 증가시킵니다. 3) 그룹 복제는 고 가용성 요구 사항에 적합한 다중 마스터 복제 및 장애 조치를 지원합니다.

설명 설명은 SQL 쿼리 성능을 분석하고 개선하는 데 사용될 수 있습니다. 1. 쿼리 계획을 보려면 설명 명세서를 실행하십시오. 2. 출력 결과를 분석하고 액세스 유형, 인덱스 사용량 및 조인 순서에주의를 기울이십시오. 3. 분석 결과를 기반으로 인덱스 생성 또는 조정, 조인 작업을 최적화하며 전체 테이블 스캔을 피하여 쿼리 효율성을 향상시킵니다.

논리 백업에 mysqldump를 사용하고 핫 백업을 위해 mysqlenterprisebackup을 사용하는 것은 mySQL 데이터베이스를 백업하는 효과적인 방법입니다. 1. MySQLDUMP를 사용하여 데이터베이스를 백업합니다 : MySQLDUMP-UROOT-PMYDATABASE> MYDATABASE_BACKUP.SQL. 2. Hot Backup : MySQLBackup- 사용자 = root-password = password-- backup-dir =/path/to/backupbackup에 mysqlenterprisebackup을 사용하십시오. 회복 할 때 해당 수명을 사용하십시오

느린 MySQL 쿼리의 주된 이유는 인덱스의 누락 또는 부적절한 사용, 쿼리 복잡성, 과도한 데이터 볼륨 및 불충분 한 하드웨어 리소스가 포함됩니다. 최적화 제안에는 다음이 포함됩니다. 1. 적절한 인덱스 생성; 2. 쿼리 문을 최적화합니다. 3. 테이블 파티셔닝 기술 사용; 4. 적절하게 하드웨어를 업그레이드합니다.

MySQL View는 SQL 쿼리 결과를 기반으로 한 가상 테이블이며 데이터를 저장하지 않습니다. 1) 뷰는 복잡한 쿼리를 단순화하고 2) 데이터 보안을 향상시키고 3) 데이터 일관성을 유지합니다. 뷰는 테이블처럼 사용할 수있는 데이터베이스에 저장된 쿼리이지만 데이터는 동적으로 생성됩니다.


핫 AI 도구

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

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

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

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

드림위버 CS6
시각적 웹 개발 도구

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

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

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기

DVWA
DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는
