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

Why does open PrepareStmt perform Prepare in advance #6493

Closed
demoManito opened this issue Aug 2, 2023 · 3 comments
Closed

Why does open PrepareStmt perform Prepare in advance #6493

demoManito opened this issue Aug 2, 2023 · 3 comments
Assignees
Labels
type:question general questions

Comments

@demoManito
Copy link
Member

demoManito commented Aug 2, 2023

Your Question

image
	db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{
		PrepareStmt: true,
	})

gorm 开启 PrepareStmt,会在执行之前多执行一次 Prepare?想问下多执行一次 Prepare 和在 Execute 之前执行的 Prepare 有什么区别,这么做的目的是什么

The document you expected this should be explained

Expected answer

@demoManito demoManito added the type:question general questions label Aug 2, 2023
@demoManito
Copy link
Member Author

@jinzhu @a631807682

@a631807682
Copy link
Member

PrepareStmt is to support https://pkg.go.dev/database/sql#Conn.PrepareContext
But the driver may implement prepare at the time of query, which may cause duplication.

@demoManito
Copy link
Member Author

PrepareStmt is to support pkg.go.dev/database/sql#Conn.PrepareContext But the driver may implement prepare at the time of query, which may cause duplication.

明白了,感谢大佬

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

No branches or pull requests

3 participants