[GENERAL] Clustered indexes - When to use them?

2005-11-02 Thread MaXX
Hi, Is there any "rule of thumb" on when to (not) use clustered indexes? What appen to the table/index? (any change on the physical organisation?) I've seen speed improvement on some queries but I'm not sure if I must use them or not... My rows are imported in batch of 100 (once the main script ha

Re: [GENERAL] Clustered indexes - When to use them?

2005-11-02 Thread Jim C. Nasby
The key expense in doing an index scan is the amount of randomness involved in reading the base table. If a table is in the same order as the index then reading the base table will be very fast. If the table is in a completely random order compared to an index (it's correlation is low), then an ind

Re: [GENERAL] Clustered indexes - When to use them?

2005-11-02 Thread MaXX
Ok thank you, so I can consider using clustered indexes when I need to 'reorder' random data to improve the speed of a particular query... In simple words: Clustered indexes are like the alphabetical index in a book, where term are randomly distibuted in the book and regular indexes are more like

Re: [GENERAL] Clustered indexes - When to use them?

2005-11-02 Thread Scott Marlowe
On Wed, 2005-11-02 at 13:50, MaXX wrote: > Ok thank you, > so I can consider using clustered indexes when I need to 'reorder' random > data to improve the speed of a particular query... > > In simple words: > Clustered indexes are like the alphabetical index in a book, where term are > randomly di

Re: [GENERAL] Clustered indexes - When to use them?

2005-11-02 Thread Jim C. Nasby
On Wed, Nov 02, 2005 at 08:50:45PM +0100, MaXX wrote: > Ok thank you, > so I can consider using clustered indexes when I need to 'reorder' random > data to improve the speed of a particular query... > > In simple words: > Clustered indexes are like the alphabetical index in a book, where term are

Re: [GENERAL] Clustered indexes - When to use them?

2005-11-02 Thread MaXX
Jim C. Nasby wrote: > On Wed, Nov 02, 2005 at 08:50:45PM +0100, MaXX wrote: [...] >> In simple words: >> Clustered indexes are like the alphabetical index in a book, where term >> are randomly distibuted in the book and regular indexes are more like the >> table of content... >> Right? > You have t

Re: [GENERAL] Clustered indexes - When to use them?

2005-11-02 Thread MaXX
Scott Marlowe wrote: > On Wed, 2005-11-02 at 13:50, MaXX wrote: [...] >> In simple words: >> Clustered indexes are like the alphabetical index in a book, where term >> are randomly distibuted in the book and regular indexes are more like the >> table of content... >> Right? > Not really. It's more

Re: [GENERAL] Clustered indexes - When to use them?

2005-11-02 Thread Jim C. Nasby
On Wed, Nov 02, 2005 at 10:55:36PM +0100, MaXX wrote: > Jim C. Nasby wrote: > > On Wed, Nov 02, 2005 at 08:50:45PM +0100, MaXX wrote: > [...] > >> In simple words: > >> Clustered indexes are like the alphabetical index in a book, where term > >> are randomly distibuted in the book and regular index

Re: [GENERAL] Clustered indexes - When to use them?

2005-11-02 Thread Tom Lane
"Jim C. Nasby" <[EMAIL PROTECTED]> writes: > That's because unfortunately PostgreSQL only keeps statistics on > individual columns. There's no stats kept on multi-column indexes; the > best the planner can do is use the stats for the first column. That's not what we do at all: we do look at the st