-
Notifications
You must be signed in to change notification settings - Fork 4
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
additional database indexes as per TN-3308 #4396
Conversation
Release v24.7.10
- user_id - subject_id - context
- user_id - status
- subject_id - encounter_id Also added 3 JSONB index values via SQL. See parent story
- status - communication_request_id - user_id
NB, postgres ignores request for index on boolean field `active`
…ional JSONB indexes beyond current SQLAlchemy syntax.
Hello @pbugni! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2024-08-08 23:54:42 UTC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, thanks!
I re-ran the seq_vs_idx
query again and most of the highest-ranked offenders are dealt with in this PR, except user_observations
, which is now #1
relname | seq_vs_idx | seq_scan | idx_scan | rel_size | hint
-------------------------+------------+----------+-----------+-----------+---------------
user_observations | 12243365 | 12243365 | 0 | 663552 | Check indexes
questionnaire_responses | 5651062 | 5950648 | 299586 | 130998272 | Check indexes
encounter_codings | 1907006 | 1907006 | 0 | 4161536 | Check indexes
encounters | 1586471 | 3540200 | 1953729 | 88932352 | Check indexes
tou | 49417 | 49417 | 0 | 2260992 | Check indexes
…ed a bogus `tou.active` index deletion.
Thank you @ivan-c , great catch on the user_observations table. |
Using the table in TN-3308 as a guide, pencil traced the code to find the common queries on each respective table.
I'd then assemble a query using
flask shell
to get the exact SQLAlchemy syntax, and then attempt before and afterexplain $query
times, to confirm it would be of value.Note the few in the migration that are directly added via SQL
exec
as the SQLAlchemy syntax didn't support (at least I couldn't find a way).