Re: [PERFORM] Choice of bitmap scan over index scan

2010-01-10 Thread Robert Haas
On Sun, Jan 10, 2010 at 9:04 AM, Jeremy Harris wrote: > On 01/10/2010 12:28 PM, Mathieu De Zutter wrote: >> >> Sort  (cost=481763.31..485634.61 rows=1548520 width=338) (actual >> time=5423.628..6286.148 rows=1551923 loops=1) >>  Sort Key: event_timestamp > >  >  Sort Method:  external merge  Disk:

Re: [PERFORM] Choice of bitmap scan over index scan

2010-01-10 Thread Robert Haas
On Sun, Jan 10, 2010 at 10:53 AM, Kevin Grittner wrote: > seq_page_cost = 0.1 > random_page_cost = 0.1 These might not even be low enough. The reason why bitmap index scans win over plain index scans, in general, is because you make one pass through the heap to get all the rows you need instead

Re: [PERFORM] PG optimization question

2010-01-10 Thread Robert Haas
2010/1/10 Pierre Frédéric Caillaud : > >> If you transfer (delete from staging, insert into archive) in one >> transaction , then it will be always visible in exactly one of them, >> and exatly once in a view over both staging and archive(s). > >        Does the latest version implement this : > >

Re: [PERFORM] Choice of bitmap scan over index scan

2010-01-10 Thread Kevin Grittner
I wrote: > work_mem = 32MB Hmmm... With 100 connections and 2 GB RAM, that is probably on the high side, at least if you sometimes use a lot of those connections at the same time to run queries which might use sorts or hashes. It's probably safer to go down to 16MB or even back to where you ha

Re: [PERFORM] Choice of bitmap scan over index scan

2010-01-10 Thread Kevin Grittner
Mathieu De Zutter wrote: > Intel(R) Core(TM)2 Duo CPU E7200 @ 2.53GHz > 2GB RAM > 2x500GB RAID-1 > Running Debian/Etch AMD64 > PG version: PostgreSQL 8.3.8 on x86_64 > Server also runs DNS/Mail/Web/VCS/... for budget reasons. > Database size is 1-2 GB. Also running copies of it for testing/d

Re: [PERFORM] Choice of bitmap scan over index scan

2010-01-10 Thread Mathieu De Zutter
On Sun, Jan 10, 2010 at 4:18 PM, Kevin Grittner wrote: > Mathieu De Zutter wrote: > > You didn't include any information on your hardware and OS, which can > be very important. Also, what version of PostgreSQL is this? > SELECT version(); output would be good. > Intel(R) Core(TM)2 Duo CPU

Re: [PERFORM] Choice of bitmap scan over index scan

2010-01-10 Thread Kevin Grittner
Mathieu De Zutter wrote: You didn't include any information on your hardware and OS, which can be very important. Also, what version of PostgreSQL is this? SELECT version(); output would be good. > How can I make pgsql realize that it should always pick the index > scan? That would probably

Re: [PERFORM] Choice of bitmap scan over index scan

2010-01-10 Thread Jeremy Harris
On 01/10/2010 12:28 PM, Mathieu De Zutter wrote: Sort (cost=481763.31..485634.61 rows=1548520 width=338) (actual time=5423.628..6286.148 rows=1551923 loops=1) Sort Key: event_timestamp > Sort Method: external merge Disk: 90488kB -> Seq Scan on log_event (cost=0.00..79085.92 rows=154

[PERFORM] Choice of bitmap scan over index scan

2010-01-10 Thread Mathieu De Zutter
Hi, Part of a larger problem, I'm trying to optimize a rather simple query which is basically: SELECT * FROM table WHERE indexed_column > ... ORDER BY indexed_column DESC; (see attachment for all details: table definition, query, query plans) For small ranges it will choose an index scan which i

Re: [PERFORM] PG optimization question

2010-01-10 Thread Pierre Frédéric Caillau d
If you transfer (delete from staging, insert into archive) in one transaction , then it will be always visible in exactly one of them, and exatly once in a view over both staging and archive(s). Does the latest version implement this : INSERT INTO archive (...) DELETE FROM staging WHE