ejc-sql icon indicating copy to clipboard operation
ejc-sql copied to clipboard

Speed up auto-completion when using company

Open dvzubarev opened this issue 1 year ago • 4 comments

This is follow-up of https://github.com/kostafey/ejc-sql/issues/141 Completions on words feels very slow. You can benchmark it with following code:

(require 'benchmark)
(benchmark-elapse (ejc-company-candidates "se"))

It gives results in range of 0.3 - 0.5 seconds. Completion time reduces to 0.0011 after this change.

If the point is on dot (name.| or name.var|), then synchronously collect candidates. Otherwise use cached data. When cache is empty (first time invocation), it returns only common SQL words and schedules the cache update. Delayed cache update is done via run-with-idle-timer. Also cache is updated when it is older than ejc-company-cache-update-ivl-secs (60 by default).

Also these changes helps in case of fatal server error (like https://github.com/kostafey/ejc-sql/issues/155). Company will complete common sql keywords and report the error, instead of just reporting the error.

dvzubarev avatar Oct 03 '23 22:10 dvzubarev