Re: [PERFORM] Sequential scan instead of index scan

2012-08-07 Thread Jeff Janes
On Tue, Aug 7, 2012 at 9:06 AM, Ioannis Anagnostopoulos wrote: > On 07/08/2012 17:00, Jeff Janes wrote: >> >> What happens if you set "enable_seqscan=off" and run the query with >> the very large list? (This is an experiment, not a recommendation for >> production use) >> >> >> Cheers, >> >> Jeff

Re: [PERFORM] Sequential scan instead of index scan

2012-08-07 Thread Ioannis Anagnostopoulos
On 07/08/2012 17:00, Jeff Janes wrote: On Mon, Aug 6, 2012 at 8:08 AM, Ioannis Anagnostopoulos wrote: Hi, my query is very simple: select msg_id, msg_type, ship_pos_messages.pos_georef1, ship_pos_messages.pos_georef2, ship_pos_me

Re: [PERFORM] Sequential scan instead of index scan

2012-08-07 Thread Jeff Janes
On Mon, Aug 6, 2012 at 8:08 AM, Ioannis Anagnostopoulos wrote: > Hi, my query is very simple: > > select > msg_id, > msg_type, > ship_pos_messages.pos_georef1, > ship_pos_messages.pos_georef2, > ship_pos_messages.pos_georef3, >

Re: [PERFORM] Sequential scan instead of index scan

2012-08-07 Thread Ioannis Anagnostopoulos
Offhand I'd have thought that ANALYZE would gather stats on the date_trunc expression (because it is indexed) and then you should get something reasonably accurate for a comparison to a constant. "Reasonably accurate" meaning "not off by two orders of magnitude". Practically all of your runtime is

Re: [PERFORM] Sequential scan instead of index scan

2012-08-06 Thread Tom Lane
Ioannis Anagnostopoulos writes: > On 06/08/2012 16:34, Tom Lane wrote: >> What you should probably be looking for is a hash join plan. > ... > Which is a Merge join and not a hash. Any ideas how to make it a hash join? You might need to ANALYZE the temp table, if you didn't already. Also it mig

Re: [PERFORM] Sequential scan instead of index scan

2012-08-06 Thread Ioannis Anagnostopoulos
On 06/08/2012 16:34, Tom Lane wrote: Ioannis Anagnostopoulos writes: I think this is a pretty good plan and quite quick given the size of the table (88Million rows at present). However in real life the parameter where I search for msg_id is not an array of 3

Re: [PERFORM] Sequential scan instead of index scan

2012-08-06 Thread Tom Lane
Ioannis Anagnostopoulos writes: > I think this is a pretty good plan and quite quick given the > size of the table (88Million rows at present). However in real > life the parameter where I search for msg_id is not an array of > 3 ids but of 300.000 or more. It is th

Re: [PERFORM] Sequential scan instead of index scan

2012-08-06 Thread Ioannis Anagnostopoulos
They are random as the data are coming from multiple threads that are inserting in the database. I see what you say about "linking them", and I may give it a try with the date. The other think that "links" them together is the 4 georef fields, however at that stage I am trying to collect statis

Re: [PERFORM] Sequential scan instead of index scan

2012-08-06 Thread David Barton
Hi Yiannis, Is there anything linking these ids together, or are the relatively random? If they are relatively random, the rows are likely to be sprinkled amongst many blocks and so a seq scan is the fastest. I've seen similar problems with indexed queries in a multi-tennant database where t

[PERFORM] Sequential scan instead of index scan

2012-08-06 Thread Ioannis Anagnostopoulos
Hi, my query is very simple: select msg_id, msg_type, ship_pos_messages.pos_georef1, ship_pos_messages.pos_georef2, ship_pos_messages.pos_georef3, ship_pos_messages.pos_georef4, obj_id, ship_speed,