gosnowflake icon indicating copy to clipboard operation
gosnowflake copied to clipboard

Cache tz -> *time.Location results

Open tysonmote opened this issue 2 years ago • 2 comments

Description

snowflakeRows.Next calls getCurrentLocation for every row, which means that the driver calls time.LoadLocation (which loads the TZ database) for every single row in the results of a query. Instead, we should only fetch it once, which we can do on the Config object.

In a simple application that runs queries and fetches a large number of rows, getCurrentLocation accounts for 65% of our overall CPU usage:

image

Checklist

  • [x] Code compiles correctly
  • [x] Run make fmt to fix inconsistent formats
  • [x] Run make lint to get lint errors and fix all of them
  • [ ] Created tests which fail without the change (if possible)
  • [ ] All tests passing
  • [ ] Extended the README / documentation, if necessary

tysonmote avatar Sep 26 '22 21:09 tysonmote

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

github-actions[bot] avatar Sep 26 '22 21:09 github-actions[bot]

I have read the CLA Document and I hereby sign the CLA

tysonmote avatar Sep 26 '22 22:09 tysonmote