Code Monkey home page Code Monkey logo

Comments (13)

keegancsmith avatar keegancsmith commented on August 25, 2024

I think a good change would be to change the API to pass args as []driver.NamedValue rather than []interface{}.

from sqlhooks.

qustavo avatar qustavo commented on August 25, 2024

That might work, it's a trade-off between performance and API simplicity, WDYT?

from sqlhooks.

keegancsmith avatar keegancsmith commented on August 25, 2024

You can export the convenience function namedToInterface to simplify it for users. You could even take an existing Hooks and convert it to a FastHooks (where FastHooks takes the []driver.NamedValue).

But this should be tested/profiled first. It may be due to the different paths database/sql takes based on the interfaces sqlhooks.Conn implements. For example if the benchmark did a db.Exec instead of a db.Query then after my recent PR you should notice it being a lot faster.

from sqlhooks.

qustavo avatar qustavo commented on August 25, 2024

That makes a lot of sense, I totally agree with your approach

from sqlhooks.

CarbonFactory avatar CarbonFactory commented on August 25, 2024

Any update on the above discussion?

from sqlhooks.

qustavo avatar qustavo commented on August 25, 2024

I haven't been able to try it, but FastHooks makes lot of sense to me. What's your use case and how do you think it could be improved?

from sqlhooks.

qustavo avatar qustavo commented on August 25, 2024

ping @CarbonFactory

from sqlhooks.

CarbonFactory avatar CarbonFactory commented on August 25, 2024

Hello, sorry did not notice the reply. I'm executing few big stored procedures and want to log the timings. Seeing the issue that the performance could be improved, I wanted to know if it is going to be implemented or not. As I don't want to add extra overhead on the already slower queries.

Also, I want to populate the Audit columns such as CreatedBy/Date and UpdatedBy/Date using a hook.
Is that even possible? Currently, I'm doing it manually for each SQL as I want to stay away from the bulky ORMs :D

from sqlhooks.

qustavo avatar qustavo commented on August 25, 2024

If your use case is to execute long stored procedures, then the overhead imposed by sqlhook should be negligible.

from sqlhooks.

qustavo avatar qustavo commented on August 25, 2024

Regarding your question about updating a column I don't think that's possible with sqlhooks without doing some black-magic, basically because you can't modify the query. Can u confirm @keegancsmith ?
The only way can imagine is to execute an UPDATE query into an After hook, you'll need to analyze or parse.

from sqlhooks.

keegancsmith avatar keegancsmith commented on August 25, 2024

sqlhooks doesn't let you do that right now + doing this in this layer would require parsing the SQL query. TBH it doesn't sound appropriate for sqlhooks pkg, and also sounds like a tricky path to follow if you forked sqlhooks to do your bidding. Can you not rely on db hooks / update your queries.

from sqlhooks.

surki avatar surki commented on August 25, 2024

@qustavo btw, the perf numbers in the README are not up to date, can we please update them?
From previous discussion here, the overhead is very minimal/negligible now.

from sqlhooks.

qustavo avatar qustavo commented on August 25, 2024

Sure, would you mind opening a PR with the update? Maybe we could close this issue too. Personally I haven't check the numbers.

from sqlhooks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.