crecto icon indicating copy to clipboard operation
crecto copied to clipboard

Necessity of RETURNING *

Open repomaa opened this issue 7 years ago • 3 comments

The reason for RETURNING * on inserts and updates is probably for setting database-level column defaults to the model instance. I wonder if this is something that should be done by default. maybe an optional Query#returning method could be introduced which would allow setting this to field names like in Query#select.

repomaa avatar Aug 27 '18 18:08 repomaa

Returning nothing or only the primary key value could be a real performance boost.

repomaa avatar Aug 27 '18 18:08 repomaa

Same applies of course to other adapters that use SELECT with LAST_INSERTED_ID()

repomaa avatar Aug 28 '18 11:08 repomaa

I knew there would be a performance decrease (especially on mysql and sqlite) at the cost of having the newly inserted record id.

I think defaulting to not returning this and providing an option to include it makes sense.

fridgerator avatar Aug 30 '18 17:08 fridgerator