[PERFORM] Deceiding which index to use

2007-03-09 Thread Mezei Zoltán
Hi! I have two tables with some indices on them: CREATE TABLE subscriber (   id serial NOT NULL,   anumber character varying(32) NOT NULL,   CONSTRAINT subscriber_pk PRIMARY KEY (id) ) CREATE INDEX anumber_idx_numeric   ON subscriber   USING btree   (anumber::numeric); CREATE TABLE output_

Re: [PERFORM] Deceiding which index to use

2007-03-09 Thread Mezei Zoltán
Richard Huxton wrote: > Mezei Zoltán wrote: > Q1. Why are you storing a numeric in a varchar? Because it's not always numeric info. :/ > Q2. How many unique values does anumber have? And how many rows in > subscriber? About 10k distinct anumbers and 20k rows. Nothing speci

Re: [PERFORM] Deceiding which index to use

2007-03-09 Thread Mezei Zoltán
Title: Re: [PERFORM] Deceiding which index to use Richard Huxton wrote: And does the planner know that? SELECT * FROM pg_stats WHERE tablename='subscriber' AND attname='anumber'; It's the n_distinct you're interested in, and perhaps most_common_freqs. n_distinct is -0.359322 an

Re: [PERFORM] Deceiding which index to use

2007-03-09 Thread Mezei Zoltán
Title: Re: [PERFORM] Deceiding which index to use Richard Huxton wrote: OK - so the next place to look is the distribution of values for subscriber_id on the output_message_log. Does that have some subscribers with many rows and lots with hardly any? Hmm... There are about 1.5k su

Re: [PERFORM] Deceiding which index to use

2007-03-09 Thread Mezei Zoltán
Title: Re: [PERFORM] Deceiding which index to use Richard Huxton wrote: There is a cost to increasing the stats values, otherwise it'd already be set at 1000. In your case I'm not sure if 100-200 vs 8-9 messages is enough to skew things. Only one way to find out... Well, I trie

Re: [PERFORM] Deceiding which index to use

2007-03-09 Thread Mezei Zoltán
Alvaro Herrera wrote: Would you mind instructing your mail system to skip converting your text/plain messages to HTML? It's kind of annoying for some of us. PostgreSQL Replication, Consulting, Custom Development, 24x7 support Sorry about that - is this message OK now? Zizi -