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

Expensive SQL query inside ensureVersionTable & ensureLockTable #1052

Open
deepakd10 opened this issue Mar 13, 2024 · 0 comments
Open

Expensive SQL query inside ensureVersionTable & ensureLockTable #1052

deepakd10 opened this issue Mar 13, 2024 · 0 comments

Comments

@deepakd10
Copy link

deepakd10 commented Mar 13, 2024

Is your feature request related to a problem? Please describe.

While creating cockroachdb instance via WithInstance(). Checks are made to ensure that version & Lock tables are created.
These two function tap into information_schema.tables. Which is an expensive query. ~15 Sec each.

withinstance() function location ->

query := `SELECT COUNT(1) FROM information_schema.tables WHERE table_name = $1 AND table_schema = (SELECT current_schema()) LIMIT 1`

ensureLockTable() function location ->

query := `SELECT COUNT(1) FROM information_schema.tables WHERE table_name = $1 AND table_schema = (SELECT current_schema()) LIMIT 1`

ensureVersionTable() function location ->

query := `SELECT COUNT(1) FROM information_schema.tables WHERE table_name = $1 AND table_schema = (SELECT current_schema()) LIMIT 1`

Describe the solution you'd like

Ideas :

  1. Let the user pass-on the query string for both the functions.
  2. Introduce another field ValidateTables to Config
type Config struct {
	MigrationsTable string
	LockTable       string
	ForceLock       bool
	DatabaseName    string
	// this will the new field, for users to Enable/Disable validations.
        ValidateTables bool
}

Additional context

If we skip this validation the migration which takes ~30 Secs is reduced to < 1Sec

@deepakd10 deepakd10 changed the title Allow users to overwrite ensureVersionTable & ensureLockTable Expensive SQL query inside ensureVersionTable & ensureLockTable Mar 13, 2024
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