This repository has been archived by the owner on Feb 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go sql: add option to panic on non-indexed queries
In this commit we add the ability to instrument a connection with a boolean that, when enabled, will have a query panic when no index is present in a sql explain for that query. We also add the ability to bypass this check on any given query in SelectOptions. Additionally we add some thin wrappers to our query functions to set this option. This will permit us to enable this check in tests and have people explicitly make full table scan queries when they fully intend to. Implementation detail: We check both key and possible keys since there are times where key will be non-null (eg PRIMARY) while possible keys is null, and also times when key is null, but possible keys is not null (eg when mysql chooses a full scan despite the presence of an index due to small table size)
- Loading branch information
Showing
4 changed files
with
160 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters