Skip to content

Possibly much better performance creating the array #2

@KaliszAd

Description

@KaliszAd

Hi this code:

(if-let [elem-type (when (= (first type-name) \_)
                            (apply str (rest type-name)))]
         (.setObject s i (.createArrayOf conn elem-type (to-array v)))
         (.setObject i s v))

https://github.com/andersmurphy/clj-cookbook/blob/f200a33c4bc961703ccf3400be9ea0324cf025d8/sql/in-any-all/src/in_any_all/core.clj#L17C1-L18C59

could probably be sped up considerably without any impact to functionality.

(if-let [elem-type (when (str/starts-with? type-name "_") (subs type-name 1))]
        (.setObject stmt idx (.createArrayOf conn elem-type (to-array v)))
        (.setObject stmt idx (clj->pgobj v)))

Yes, we are splitting microseconds here. It's just that slightly better performance isn't even less readable in this case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions