Re: PostgreSQL BugTool Submission - Mailing list pgsql-bugs

From Tom Lane
Subject Re: PostgreSQL BugTool Submission
Date
Msg-id 20949.967089135@sss.pgh.pa.us
Whole thread Raw
In response to PostgreSQL BugTool Submission  (pgsql-bugs@postgresql.org)
List pgsql-bugs
pgsql-bugs@postgresql.org writes:
> When performing a query against a table that has a 64bit (int8)
> primary key a sequential scan always takes place.

Possibly a casting issue.  Observe:

regression=# create table foo1 (f1 int8 primary key);
NOTICE:  CREATE TABLE/PRIMARY KEY will create implicit index 'foo1_pkey' for table 'foo1'
CREATE
regression=# explain select * from foo1 where f1 = 42;
NOTICE:  QUERY PLAN:

Seq Scan on foo1  (cost=0.00..22.50 rows=10 width=8)

EXPLAIN
regression=# explain select * from foo1 where f1 = 42::int8;
NOTICE:  QUERY PLAN:

Index Scan using foo1_pkey on foo1  (cost=0.00..8.14 rows=10 width=8)

EXPLAIN

The planner is not currently very smart about figuring out whether a
cross-data-type operator (int8-vs-int4-equal, here) can be munged into
the single-data-type operator that's associated with an index.  An
explicit cast will prod it in the right direction.

We do plan to fix this, but there's still some debate about how...

            regards, tom lane

pgsql-bugs by date:

Previous
From: pgsql-bugs@postgresql.org
Date:
Subject: PostgreSQL BugTool Submission
Next
From: pgsql-bugs@postgresql.org
Date:
Subject: PostgreSQL BugTool Submission