Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new_execution incurs unnecessary performance hit #6

Open
bsanders1979 opened this issue Oct 29, 2011 · 1 comment
Open

new_execution incurs unnecessary performance hit #6

bsanders1979 opened this issue Oct 29, 2011 · 1 comment

Comments

@bsanders1979
Copy link

mysql.rb:411-414
...
metadata = res.result_metadata rescue nil

if metadata
columns = res.result_metadata.fetch_fields.collect do |col|
...

I was profiling my code to find bottlenecks and discovered that result_metadata was costing me a lot of CPU time
Line should be: columns = metadata.fetch_fields

Also, seems like metadata/columns/schema should only be calculated once unless there's a good reason why it shouldn't be.

@bsanders1979
Copy link
Author

I have re-factored this function such that schema has been converted to an instance variable that is lazily initialized upon the first execution of the prepared statement. The end result is that my engine now runs over 6 times faster and maintains consistent throughput which is a big deal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant