|
|
Sponsor |
Re: index is not used: msg#00148db.postgresql.novice
mila boldareva <pierro@xxxxxx> writes: > ... but the index on real field3 is used only when I > ask ordering, and a query like below remains seq. scan: > trc=# explain select * from mytable where field3 = 0.1 limit 1; Unadorned "0.1" will be taken as a float8 (double precision) constant, and the system is not currently smart enough to convert a cross-datatype comparison (viz, float4 vs float8) into an indexscan. You can either change the field type to double precision or write an explicit coercion: select * from mytable where field3 = 0.1::real limit 1; A hack that some people use instead is to quote the constant, even though it's numeric: select * from mytable where field3 = '0.1' limit 1; It turns out that this causes the system to postpone assigning a specific type to the constant until late enough in processing the query that it knows float4 is the best choice instead of float8. This is basically the same story as for int2 and int8 columns. It's pretty ugly, and fixing it is on the TODO list. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | configure options, Hugh Scully |
|---|---|
| Next by Date: | Re: Simple but slow, Josh Berkus |
| Previous by Thread: | Re: index is not used, mila boldareva |
| Next by Thread: | Event recurrence - in database or in application code ????, Darrin Domoney |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home | sitemap
| advertise | OSDir is
an inevitable website.
|