node.js - Performance penalty in executing native SQL in Strongloop Loopback -


is there disadvantage execute native sql query using either {datasource.connector.execute(sql, params, cb) or datasource.connector.query(sql, params, cb)} using connected models?

i have tested same scenario sample data both native sql , connected models. when used native sql noticed mysql connection lost when increase load. same operations performance loopback's connected models , filters, can sustain 4 times load compared native sql connector.

loopback don't recommend using native sql connector:

this feature has not been tested , not officially supported: api may change in future releases. in general, better perform database actions through connected models. directly executing sql may lead unexpected results, corrupted data, , other issues. - loopback

so exact question has noticed disadvantage or performance panalty using of using native sql instead of loopback's connected models?

simply put running raw queries(native sql) may faster having using orms(models) perform validations , build queries parameters , filters provide etc. running raw queries issue query connected sql server on network without going through layers , difference maybe barely noticeable. industry standard should use orms(models) access data protect lot of threats sql injection , simple human errors performs comprehensive validations based on schema. put orms safer raw queries. matter of choice want do. fall somewhere in middle use orm provided models whenever possible have found instances running raw queries brings far more simplicity when have perform joins on more 2 tables manipulate data using queries use orm. last bit way of doing things in many peoples opinion may wrong. suggest use orms ie. in case strong loop connectors as possible.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -