Re: [SQL] Indexes and statistics

2004-02-18 Thread Iain
> The computed cost of using the index was a factor of 10 higher which I presume is why the query planner wasn't > using the index, but it ran in half the time Have you tried playing with the random_page_cost parameter? The default is 4. Try: set random_page_cost = 1; in psql to alter it for th

Re: [SQL] Indexes and statistics

2004-02-18 Thread Tom Lane
"David Witham" <[EMAIL PROTECTED]> writes: > Does this make it a "wide" table? Nope. A rough estimate is that your rows will be about 160 bytes wide, which means you can fit about 50 per 8K page. So a query that needs to select 8% of the table will *on average* need to hit about 4 rows per page.

Re: [SQL] Indexes and statistics

2004-02-17 Thread David Witham
e. I hope this makes sense. Does it help any? Thanks, David -Original Message- From: Tom Lane [mailto:[EMAIL PROTECTED] Sent: Wednesday, 18 February 2004 16:10 To: David Witham Cc: [EMAIL PROTECTED] Subject: Re: [SQL] Indexes and statistics "David Witham" <[EMAIL PROTECTED]&g

Re: [SQL] Indexes and statistics

2004-02-17 Thread Tom Lane
"David Witham" <[EMAIL PROTECTED]> writes: > One of the customers is quite large (8.3% of the records): Hmm. Unless your rows are quite wide, a random sampling of 8.3% of the table would be expected to visit every page of the table, probably several times. So the planner's cost estimates do not

[SQL] Indexes and statistics

2004-02-17 Thread David Witham
Hi all, This is a further post from last week. I've got a table of phone call detail records. buns=# select count(*) from cdr; count - 2800653 (1 row) One of the customers is quite large (8.3% of the records): buns=# select count(*) from cdr where cust_id =