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

Add select_db as an alias for change_db #101

Merged

Conversation

HeyNonster
Copy link
Contributor

select_db is the method name in the mysql2 gem and also seems to be the preferred nomenclature in the mysql documentation.

AFAICT, both use COM_INIT_DB under the hood. Having select_db as an alias will make it easier to transition from mysql2 -> trilogy (even if this likely isn't used that frequently)

There seems to be no noticable performance penalty for using the alias, at least with Ruby 3.2.2:

ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]
Warming up --------------------------------------
              native     1.260M i/100ms
               alias     1.265M i/100ms
Calculating -------------------------------------
              native     12.583M (± 1.0%) i/s -     63.025M in   5.009167s
               alias     12.538M (± 1.0%) i/s -     63.257M in   5.045579s

Comparison:
              native: 12583154.1 i/s
               alias: 12538412.7 i/s - same-ish: difference falls within error

`select_db` is the method name in the mysql2 gem and also seems to be
the preferred nomenclature in the [mysql documentation](https://dev.mysql.com/doc/c-api/5.7/en/mysql-select-db.html).

AFAICT, both use `COM_INIT_DB` under the hood. Having `select_db` as an
alias will make it easier to transition from `mysql2` -> `trilogy` (even
if this likely isn't used _that_ frequently)

There seems to be no noticable performance penalty for using the alias,
at least with Ruby 3.2.2:

```
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]
Warming up --------------------------------------
              native     1.260M i/100ms
               alias     1.265M i/100ms
Calculating -------------------------------------
              native     12.583M (± 1.0%) i/s -     63.025M in   5.009167s
               alias     12.538M (± 1.0%) i/s -     63.257M in   5.045579s

Comparison:
              native: 12583154.1 i/s
               alias: 12538412.7 i/s - same-ish: difference falls within error
```
Copy link
Member

@jhawthorn jhawthorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jhawthorn jhawthorn merged commit a97c8d3 into trilogy-libraries:main Aug 2, 2023
12 checks passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants