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@gmx.net 75262 Uppsala
http://yi.org/peter-e/ Sweden