From: | Christophe Pettus <xof(at)thebuild(dot)com> |
---|---|
To: | arun chirappurath <arunsnmimt(at)gmail(dot)com> |
Cc: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: Seq scan vs index scan |
Date: | 2024-03-23 04:02:18 |
Message-ID: | 5FE1E177-BFDB-4386-8DDC-02A652E71C86@thebuild.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> On Mar 22, 2024, at 20:55, arun chirappurath <arunsnmimt(at)gmail(dot)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 over an index scan if the table is small, or the number of rows that come back from the query are a significant percentage of 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';
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2024-03-23 04:02:49 | Re: Seq scan vs index scan |
Previous Message | arun chirappurath | 2024-03-23 03:55:16 | Seq scan vs index scan |