Re: [GENERAL] int8 index isn't used for query against number
От | Peter Eisentraut |
---|---|
Тема | Re: [GENERAL] int8 index isn't used for query against number |
Дата | |
Msg-id | Pine.LNX.4.20.9911022213090.356-100000@peter-e.yi.org обсуждение исходный текст |
Ответ на | int8 index isn't used for query against number (Mark Dalphin <mdalphin@amgen.com>) |
Список | 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@gmx.net 75262 Uppsala http://yi.org/peter-e/ Sweden
В списке pgsql-general по дате отправления: