itwanger / itwanger/toBeBetterJavaer
面渣逆袭索引50.2题 范围查询后的列还能用索引吗?
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 17.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
范围查询后的列无法使用索引;但当范围查询应用于最左前缀的最后一列,此时仍可以使用索引。
SQL
-- 索引(a,b,c)
WHERE a=1 AND b=2 AND c>3;
-- a和b此时有序,c也按照范围查询排好序
--此时abc都可以使用索引
SQL
-- 索引(a,b,c)
SELECT * FROM table WHERE a = 1 AND b > 2 AND c = 3;
--范围查询在中间,只能使用a和b,c无法使用索引
望二哥回复,嘿嘿!不采纳也没关系二哥!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file or test is named. Start by reviewing the issue's two composite-index SQL examples and verify their range-query behavior against the project's MySQL learning material or authoritative MySQL documentation. Done means the explanation is confirmed or corrected in the relevant educational content.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, sql
- Domain
- databases, documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100