From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | Mark Dalphin <mdalphin(at)amgen(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: [GENERAL] int8 index isn't used for query against number |
Date: | 1999-11-02 21:16:15 |
Message-ID: | Pine.LNX.4.20.9911022213090.356-100000@peter-e.yi.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Nov 2, Mark Dalphin mentioned:
> -- Without quotes, no Index scan; very slow
> db=> EXPLAIN
> db-> SELECT FileID, Contig_Accession, ByteOffset, SeqLength FROM Seq S
> db-> WHERE Contig_Accession=6739795;
> NOTICE: QUERY PLAN:
>
> Seq Scan on seq s (cost=105160.20 rows=1 width=22)
>
> EXPLAIN
>
Try ... WHERE Contig_Accession = 6739795::int8. The same thing happens
with int2 I believe because integers are all assumed to be int4's and the
backend isn't too smart in that regard one could say.
> -- With quotes, index scan and almost instantaneous responce.
> db=> explain
> db-> SELECT FileID, Contig_Accession, ByteOffset, SeqLength FROM Seq S
> db-> WHERE Contig_Accession='6739795';
> NOTICE: QUERY PLAN:
>
> Index Scan using seq_contig_accession_key on seq s (cost=2.05 rows=1 width=22)
>
> EXPLAIN
Interesting. Perhaps the the fact that you give it a string forces it to
undertake some sort of typecast and it actually casts it to int8.
--
Peter Eisentraut Sernanders vaeg 10:115
peter_e(at)gmx(dot)net 75262 Uppsala
http://yi.org/peter-e/ Sweden
From | Date | Subject | |
---|---|---|---|
Next Message | Tyson Oswald | 1999-11-02 23:17:42 | selecting a certain number of rows |
Previous Message | Peter Eisentraut | 1999-11-02 21:09:49 | Re: [GENERAL] error with user |