cht-core icon indicating copy to clipboard operation
cht-core copied to clipboard

Research freetext view use to inform hosting TCO reduction

Open mrjones-plip opened this issue 6 months ago • 12 comments

Describe the issue it's been decided that storage is the highest cost for hosting total cost of ownership (TCO). It's suspected that CHT's use of CouchDB freetext views cause a large amount of disk space. But how much? How might the size of the view be reduced? Where does the UI surface the use of these views?

Describe the improvement you'd like research and document use of freetext views so we know how to safely reduce the disk use caused by using them

Describe alternatives you've considered na


Next Steps:

  • [x] Check Couch/HAProxy logs for instances of the views being used
  • [ ] community research
  • [ ] Remove views and run e2e tests and see what happens
  • [ ] Add logging for the view and manually poke around the app

Open Questions:

  • Where are the views being used programmatically?
  • What fields are being searched for?
  • What are users actually searching for?

CouchDB views for freetext searching

These get queried by the @medic/search shared lib:

These generated queries are then executed one level higher in shared-libs/search/src/search.jsThis is then imported and ran by:


logs are VERY informative, even showing the keyword freetext !here's couch logs when searching for bbbbbbbbbbbbbbbbbbbbbbbbbb:

[notice] 2024-07-31T14:12:35.171290Z [email protected] <0.16948.0> 8d6a7d7e03 192-168-68-235.local-ip.medicmobile.org 172.20.0.7 medic GET /medic/_design/medic-client/_view/contacts_by_freetext?startkey=%5B%22bbbbbbbbbbbbbbbbbbbbbbbbbb%22%5D&endkey=%5B%22bbbbbbbbbbbbbbbbbbbbbbbbbb%EF%BF%B0%22%5D 200 ok 9

As well, it shows up in HA proxy for online users when searching for aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:

<150>Jul 31 14:11:16 haproxy[12]: 172.20.0.7,couchdb,200,5,0,0,GET,/medic/_design/medic-client/_view/contacts_by_freetext?startkey=%5B%22aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%22%5D&endkey=%5B%22aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%EF%BF%B0%22%5D,-,medic,'-',276,5,-,'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0'

mrjones-plip avatar Jul 31 '24 20:07 mrjones-plip