Closed thiagoferreiraw closed 1 year ago
Hi @etianen!
Here's a performance improvement we made recently in our own codebase and we'd like to extend that to the community.
Let me know your thoughts about the proposed sollution and/or if I need to adequate the code to meet the project standards.
Thank you!
This is a great change, thank you!
Context
After running some performance tests, I realized the way we are casting types for the
model primary key
vssearchentry.object_id
was unefficient.When we do a
model.uuid_pk::text
conversion, postgres lose the ability to use the primary key index and that makes the query way slower.Queries and plans (testing with 100k records)
Note the primary key index was not used because of a type cast (partnershipledger.id::text)
In nearly 100k records, the execution went from 71ms to 7ms 💯
Before
After
Proposed sollution
If the primary key is UUID, we cast type in the watson_searchentry.id instead.