-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
DDL: do not Reload() for 'CREATE TEMPORARY' and 'DROP TEMPORARY' statements #12144
DDL: do not Reload() for 'CREATE TEMPORARY' and 'DROP TEMPORARY' statements #12144
Conversation
…ements Signed-off-by: Shlomi Noach <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
If a new flag is being introduced:
If a workflow is added or modified:
Bug fixes
Non-trivial changes
New/Existing features
Backward compatibility
|
isTemporaryTable := false | ||
switch stmt := qre.plan.FullStmt.(type) { | ||
case *sqlparser.CreateTable: | ||
isTemporaryTable = stmt.IsTemporary() | ||
case *sqlparser.DropTable: | ||
isTemporaryTable = stmt.IsTemporary() | ||
} | ||
|
||
if !isTemporaryTable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the analyzeDDL plan
we mark in the plan NeedsReservedConn
to true, so we can use that field here and ignore the reload
return &Plan{PlanID: PlanDDL, FullQuery: fullQuery, FullStmt: stmt, NeedsReservedConn: stmt.IsTemporary()}, nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can there be a future scenario where NeedsReservedConn
is true
even if the table is not TEMPORARY
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've meanwhile simplified the check for IsTemporary()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not expect that to change and I have added a test specifically for that.
We can keep the current simplified version as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's keep the existing version, then, as it is more explicit 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a test for this change?
@harshit-gangal good idea; I don;t have an immediate understanding of how to test this, I'd need to dig in. If you happen to know, would you add such test? |
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Fixes #12146 |
I will add the test |
…create ddl Signed-off-by: Harshit Gangal <[email protected]>
Tests-wise, I see validation that |
I am adding a reload time metric that will help achieve that test. |
…ecuted on temporary tables Signed-off-by: Harshit Gangal <[email protected]>
f6a0cce
to
24e7c22
Compare
Description
In
query_executor.go
, inexecDDL()
, we differentiate two cases:In the latter case, we always invoke
Reload()
(specificallyReloadAtEx()
) to reload table schema.However, for
CREATE TEMPORARY TABLE
andDROP TEMPORARY TABLE
this is wasteful:Reload()
adds an overhead which becomes significant if temporary tables are created and dropped intensively.With this PR we skip
Reload()
for temporary tables.Related Issue(s)
Checklist
Deployment Notes