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

[DEA] Search Performance Improvement with custom Search filters #1317

Closed
Tracked by #790
mahalakshme opened this issue Aug 27, 2024 · 1 comment
Closed
Tracked by #790

[DEA] Search Performance Improvement with custom Search filters #1317

mahalakshme opened this issue Aug 27, 2024 · 1 comment
Assignees

Comments

@mahalakshme
Copy link
Contributor

mahalakshme commented Aug 27, 2024

Search of observations(via Search All) and name via like operator is not fast. This is the place where most of the slow queries w.r to Search are executed. Identified from newrelic. One reason is looks like GIN index is not used and right indices not added on name columns, and others.

AC:

  • When search done with 'Search All' should be faster
  • When search done with 'Name' Search filter should be faster.
  • Comment with performance improvement made before and after here in the column Time taken after improvement
  • Search with other filters also like Gender, age, Address, date filters etc., wherever possible make it faster.
  • Search without any params should be fast
  • Currently in JSCS or Ashwini - when SearchAll or search by Name is done - it takes more than 30 secs. Search by anything should take less than or equal to 3 secs.

Technical analysis:

  • Search already done as openchs user.
  • But when searching for observations, make sure GIN index is used. Modify the query with right operators if not. Considering the search with observations is slow(like in the above sheet for ashwini and many such queries in newrelic), good to make sure this.
  • For name, adding pg_trgm - https://niallburkley.com/blog/index-columns-for-like-in-postgres/ might help to search faster
  • also add index on other applicable columns like age, gender etc.,
@mahalakshme mahalakshme changed the title [DEA] Search Performance Improvement [DEA] Search Performance Improvement - phase 2 Aug 27, 2024
@mahalakshme mahalakshme changed the title [DEA] Search Performance Improvement - phase 2 [DEA] Search Performance Improvement with custom Search filters Sep 19, 2024
@petmongrels petmongrels self-assigned this Sep 23, 2024
@petmongrels
Copy link
Contributor

petmongrels commented Sep 26, 2024

As is

https://explain.dalibo.com/plan/3e9977614f1gbc7c
Cost = 24000

Simplifying query for subject type

https://explain.dalibo.com/plan/d93869c16a48c705
Cost = 4200

Not seeing like, date, or age queries show up in the explain results, so not optimising for it.

Some other plans:

petmongrels added a commit to avniproject/avni-server that referenced this issue Sep 26, 2024
petmongrels added a commit to avniproject/avni-server that referenced this issue Sep 27, 2024
himeshr pushed a commit to avniproject/avni-server that referenced this issue Oct 18, 2024
… simplified search query has lesser cost.

(cherry picked from commit 394959f)
himeshr pushed a commit to avniproject/avni-server that referenced this issue Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

3 participants