Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Document indexes and make them opt-in #205

Merged
merged 9 commits into from
Dec 28, 2021

Conversation

tiangolo
Copy link
Member

✨ Document indexes and make them opt-in

Up to now, SQLModel created indexes for each column by default. This PR changes that to make indexes only opt-in (including the same line change as in #11), and documents indexes, etc.

This PR adds a new section explaining indexes, how they work, and how to enable them for columns.

It also updates all the rest of the docs examples to use indexes accordingly and references to indexes where necessary.

It adds tests for index creation (for the new tutorial source examples) and updates other tests as needed.


The rationale for the previous behavior of having indexes by default was that it's easy for beginners to not know about indexes, not spend the time to learn about them, and get bad reading performance. It was also partly inspired by how ElasticSearch indexes everything by default, but it probably makes more sense there that everything would be intended to be searchable. But I see this approach was not very generalizable as commented here #9 and #11. So I'm reverting that approach here and instead I'm documenting and explaining indexes as best as I could after several days of working on this.

@codecov
Copy link

codecov bot commented Dec 28, 2021

Codecov Report

Merging #205 (dd453ba) into main (3d7b747) will increase coverage by 0.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #205      +/-   ##
==========================================
+ Coverage   97.43%   97.49%   +0.06%     
==========================================
  Files         177      181       +4     
  Lines        5895     6037     +142     
==========================================
+ Hits         5744     5886     +142     
  Misses        151      151              
Impacted Files Coverage Δ
docs_src/advanced/decimal/tutorial001.py 100.00% <100.00%> (ø)
..._src/tutorial/code_structure/tutorial001/models.py 100.00% <100.00%> (ø)
.../tutorial/code_structure/tutorial002/hero_model.py 100.00% <100.00%> (ø)
.../tutorial/code_structure/tutorial002/team_model.py 100.00% <100.00%> (ø)
..._src/tutorial/connect/create_tables/tutorial001.py 100.00% <100.00%> (ø)
docs_src/tutorial/connect/delete/tutorial001.py 100.00% <100.00%> (ø)
docs_src/tutorial/connect/insert/tutorial001.py 100.00% <100.00%> (ø)
docs_src/tutorial/connect/select/tutorial001.py 100.00% <100.00%> (ø)
docs_src/tutorial/connect/select/tutorial002.py 100.00% <100.00%> (ø)
docs_src/tutorial/connect/select/tutorial003.py 100.00% <100.00%> (ø)
... and 54 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d7b747...dd453ba. Read the comment docs.

@github-actions
Copy link

@github-actions
Copy link

📝 Docs preview for commit dd453ba at: https://61cae8f3eaa6703b1dc08de3--sqlmodel.netlify.app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant