Skip to content

Allow option to force index scan #3

@bensheldon

Description

@bensheldon

When querying on a table with a small number of records (like in development), the Postgres query-planner may ignore indexes in favor of sequential scans.

It would be beneficial to have an option to force Postgres to use indexes when performing the query to better simulate production behavior.

An example implementation is:

Wallet.where(base_currency: "USD").explain(analyze: true, indexscan: true)

would be equivalent to:

ActiveRecord::Base.connection.execute('SET enable_seqscan = OFF')
Wallet.where(base_currency: "USD").explain(analyze: true)
ActiveRecord::Base.connection.execute('SET enable_seqscan = ON')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions