Re: Seq scan vs index scan - Mailing list pgsql-general

From Christophe Pettus
Subject Re: Seq scan vs index scan
Date
Msg-id 5FE1E177-BFDB-4386-8DDC-02A652E71C86@thebuild.com
Whole thread Raw
In response to Seq scan vs index scan  (arun chirappurath <arunsnmimt@gmail.com>)
List pgsql-general

> On Mar 22, 2024, at 20:55, arun chirappurath <arunsnmimt@gmail.com> wrote:
> I am trying to force query to use indexes  using query hints.

PostgreSQL does not have query hints.  Enabling index scans using parameters doesn't *disable* other types of query
nodes.

You can disable sequential scans using:

    SET enable_seqscan = off;

... but more importantly, why do you want to force an index scan?  Generally, PostgreSQL will pick a sequential scan
overan index scan if the table is small, or the number of rows that come back from the query are a significant
percentageof the rows of the table. 

If you would like a more detailed answer, it would be a good idea to post an execution plan of the query with:

    EXPLAIN ANALYZE SELECT * FROM users WHERE username = 'example_username';


pgsql-general by date:

Previous
From: arun chirappurath
Date:
Subject: Seq scan vs index scan
Next
From: "David G. Johnston"
Date:
Subject: Re: Seq scan vs index scan