Re: [PERFORM] Severe performance problems for simple query

2008-04-07 Thread Florian Weimer
* Dimi Paun: > * 4.9 million records in a table (IP address info) You should use the ip4r type for that. -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance

Re: [PERFORM] Severe performance problems for simple query

2008-04-07 Thread Matthew
On Mon, 7 Apr 2008, Heikki Linnakangas wrote: In that case, a regular index on (ipFrom, ipTo) should work just fine, and that's what he's got. Actually, an index on just ipFrom would probably work just as well. The problem is that the planner doesn't know about that special relationship between

Re: [PERFORM] Severe performance problems for simple query

2008-04-07 Thread Dimi Paun
On Mon, 2008-04-07 at 17:27 +0100, Matthew wrote: > Oh yes, if you can guarantee that no two entries overlap at all, then > there is a simpler way. Just create a B-tree index on ipFrom as usual, > sort by ipFrom, and LIMIT to the first result: > > SELECT blah FROM table_name >WHERE ipFrom <=

Re: [PERFORM] Severe performance problems for simple query

2008-04-07 Thread Dimi Paun
On Mon, 2008-04-07 at 17:32 +0100, Heikki Linnakangas wrote: > If I understood the original post correctly, the ipFrom and ipTo > columns actually split a single linear ip address space into > non-overlapping chunks. Something like this: > > ipFrom ipTo > 1 10 > 10 20 > 20 50 >

Re: [PERFORM] Severe performance problems for simple query

2008-04-07 Thread Heikki Linnakangas
Matthew wrote: On Mon, 7 Apr 2008, Dimi Paun wrote: * bad performance on queries of the form: select * from ipTable where ipFrom <= val and val <= ipTo This type of query is very hard for a normal B-tree index to answer. For example, say val is half-way between min and max values. If you

Re: [PERFORM] Severe performance problems for simple query

2008-04-07 Thread Matthew
On Mon, 7 Apr 2008, Dimi Paun wrote: * bad performance on queries of the form: select * from ipTable where ipFrom <= val and val <= ipTo Oh yes, if you can guarantee that no two entries overlap at all, then there is a simpler way. Just create a B-tree index on ipFrom as usual, sort by ip

Re: [PERFORM] Severe performance problems for simple query

2008-04-07 Thread Matthew
On Mon, 7 Apr 2008, Dimi Paun wrote: * bad performance on queries of the form: select * from ipTable where ipFrom <= val and val <= ipTo This type of query is very hard for a normal B-tree index to answer. For example, say val is half-way between min and max values. If you have an index

[PERFORM] Severe performance problems for simple query

2008-04-07 Thread Dimi Paun
Hi folks, Here is the executive summary: * RHEL5 (postgresql 8.1, .conf tweaked for performance [1]) * 2x Intel E5410 @ 2.33GHz (8 cores), 8GB RAM, 15KRPM SAS disks * 4.9 million records in a table (IP address info) * composite primary key: primary key(ipFrom, ipTo) * ipFrom/ipTo are int