Skip to content

feat: add indexHint - #9409

Closed
harbolaez wants to merge 1 commit into
sequelize:v4from
harbolaez:indexHint
Closed

harbolaez wants to merge 1 commit into
sequelize:v4from
harbolaez:indexHint

Conversation

@harbolaez

@harbolaez harbolaez commented May 7, 2018 •

Copy link
Copy Markdown

Pull Request check-list

Please make sure to review and check all of these items:

  • Does npm run test or npm run test-DIALECT pass with this change (including linting)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description of change

Hi, this PR is for adding a way to add index hints to a select query by using USE or FORCE.

How to use it:

sequelize.Order.findAll({
  where: {
    statusId: 1,
  },
  indexHint: 'idx_status_id',
});

This will allow the end user to pass the indexHint different ways.

Examples:

indexHint: 'idx_status_id'

indexHint: [{value: ' USE INDEX(`idx_status_id `)'}]

indexHint: [['USE', 'idx_status_id']]

indexHint: ['idx_status_id']
This will generates

SELECT * FROM Order USE INDEX(idx_status_id) WHERE status_id = 1

I have done testing under test/unit/sql/select.test.js

@harbolaez harbolaez changed the title Index hint add indexHint May 7, 2018
@harbolaez
harbolaez changed the base branch from master to v4 May 7, 2018 15:49
@harbolaez harbolaez changed the title add indexHint feat: add indexHint May 7, 2018
@sushantdhiman sushantdhiman mentioned this pull request May 9, 2018
4 of 5 tasks
@sushantdhiman

sushantdhiman commented May 9, 2018 •

Copy link
Copy Markdown
Contributor

In past I have rejected this feature because there was little to no demand, but it seems now this feature is desired by some users.

There are three PRs related to this change #9378, #9409 & #8401

I suggest authors of these PRs or anyone else who want this feature to suggest an API #9421 and propose a single PR after API is finalized.

Looks like MySQL / MSSQL / SQLite support this feature. PR with support and tests for all these dialects will be appreciated

This was referenced May 9, 2018
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

Successfully merging this pull request may close these issues.

2 participants