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

Execution time 60s+ with 4000 databases #1603

Open
deubert-it opened this issue Nov 4, 2023 · 2 comments
Open

Execution time 60s+ with 4000 databases #1603

deubert-it opened this issue Nov 4, 2023 · 2 comments

Comments

@deubert-it
Copy link

Use Case

I'm not managing databases with puppet, however this module will always loop all databases and do a "show variables" on them.
This currently takes ~60 seconds for ~4.000 database.

Debug: Executing: '/usr/bin/mysql --defaults-extra-file=/root/.my.cnf -NBe show variables like '%_database' db_982'

Describe the Solution You Would Like

If I'm not managing databases via the module at all, maybe this information is not required for everything else to function, and the module could detect itself if it isn't managing databases.

Describe Alternatives You've Considered

An alternative could be a new parameter to just disable this behaviour on demand.

@WBasson
Copy link

WBasson commented Apr 30, 2024

We would also like this behaviour to be configureable.

@alexjfisher
Copy link
Collaborator

I assume there must be at least 1 database that this module is managing or I don't think the code would get called at all.

Perhaps instead of looping over every database and calling show variables here

def self.instances
mysql_caller('show databases', 'regular').split("\n").map do |name|
attributes = {}
mysql_caller(["show variables like '%_database'", name], 'regular').split("\n").each do |line|
k, v = line.split(%r{\s})
attributes[k] = v
end
new(name: name,
ensure: :present,
charset: attributes['character_set_database'],
collate: attributes['collation_database'])
end
end

a single query of the information_schema database could do the job.

ie this single query should return everything required to create the mysql_database instances. select SCHEMA_NAME,DEFAULT_CHARACTER_SET_NAME,DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA;

It'd need testing on all the mysql variants the module supports though...

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

No branches or pull requests

4 participants